|
|
View previous topic :: View next topic |
Author |
Message |
Kit Guest
|
What is output_float() for? |
Posted: Sat Jul 16, 2005 6:51 pm |
|
|
Hi,
I don't understanding the function of output_float(). According to the Help files, "Sets the specified pin to the input mode. ".
In what situatio we need to use it?
I found it in 2432.c, under Drivers folder.
Thanks. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sat Jul 16, 2005 7:13 pm |
|
|
I used output float once to out the pin into the high impedance mode. The analog dc signal was connected to the digital pin. When the pin was high impedance, the analog signal was flowing. After ouptut_low() the signal was grounded.
Kender |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Sat Jul 16, 2005 7:15 pm |
|
|
I suppose it's just another term for "make it an input."
As for where you'd need it, a perfect example is the DS18S20 one-wire temperature sensor. It only has one bidirectional data line, which is an open drain, pulled up with an external R.
Every transaction is started with the master pulling the data line low, then either holding it low, or releasing the line, depending on whether you're writing to it, what you're writing to it, or reading from it. The output_float() command would work perfectly there. |
|
|
Kit Guest
|
|
Posted: Sat Jul 16, 2005 7:47 pm |
|
|
If we need to read from the pin, we can simply use
input_x() function.
I really cann't see why we need output_float(). |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Jul 16, 2005 9:45 pm |
|
|
output_float() doesn't read the value. It controls the tris register. It is different than input(). With standard i/o, an input will affect the tris while reading the value. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sun Jul 17, 2005 2:38 pm |
|
|
Output_float is slightly faster than reading the pin and doesn't require any scratch space to put what would be read.
One case where I used Output_float was when several PICs in a group shared a "Busy" line. There was a resistor pull down on the line. Whenever any of the PICs was busy it pulled the line high, indicating the group was busy. When the PIC was no longer busy it used Output_float to let go of the line, but it did not know if another PIC might also be asserting the line. If the line dropped then the group was no longer busy. If the line did not drop then some other PIC must still be busy so the group is still busy. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
MTT Guest
|
output_float() discussion |
Posted: Tue Apr 04, 2006 5:09 am |
|
|
Hello everybody,
Reading the held provided by CCS I extracted that the output_float() can be used in open collector connections where the digital line only has two modes:
- Ground the line. (0 Volts)
- Set the line in high impedance (current through the line of 0 Amps)
I use it to induce a device to shutdown mode. This device goes to shutdown with a specific pin to GND. If no shutdown is desired, a pull-up resistor drives this pin to high level.
output_float() is great to manage that pin. When I don't want the device to go to shutdown mode I simply execute a output_float(PIN) and ,as far as the device is concerned, no connection exists between him and the micro-processor PIC. |
|
|
Arakel
Joined: 06 Aug 2016 Posts: 107 Location: Moscow
|
Re: output_float() discussion |
Posted: Thu Aug 17, 2017 5:59 am |
|
|
MTT wrote: | Hello everybody,
Reading the held provided by CCS I extracted that the output_float() can be used in open collector connections where the digital line only has two modes:
- Ground the line. (0 Volts)
- Set the line in high impedance (current through the line of 0 Amps)
I use it to induce a device to shutdown mode. This device goes to shutdown with a specific pin to GND. If no shutdown is desired, a pull-up resistor drives this pin to high level.
output_float() is great to manage that pin. When I don't want the device to go to shutdown mode I simply execute a output_float(PIN) and ,as far as the device is concerned, no connection exists between him and the micro-processor PIC. |
Sorry to bring up an old thread, but I like certain things!
1. So "output_float" disregards what is on the pin?
2. On the pin we can have a grounded signal pulled by the external circuit or a "1" meaning "5V" and the MCU will disregard both of them?
3. The "output_float" puts the pin in the high-impedance state, because all pins can be "input, output, high-impedance", this is why they are 3-state pins.
4. The value is not recorded in "PORTA" but is recorded in "TRISA" ?
5. What is the "high impedance state" used for anyway? How much is this impedance?
6. Why not just leave the pin uninitialized?
7. When using this state with "EEPROM 2432", what exactly is it used for?
EDIT A SECOND TIME:
8. The processor, not the external circuit pulls the pin low and records a "0" in the "TRISA" register (of its on the "RA" pins of course)
Code: |
///////////////////////////////////////////////////////////////////////////
//// Library for a MicroChip 24C32 ////
//// ////
//// init_ext_eeprom(); Call before the other functions are used ////
//// ////
//// write_ext_eeprom(a, d); Write the byte d to the address a ////
//// ////
//// d = read_ext_eeprom(a); Read the byte d from the address a ////
//// ////
//// b = ext_eeprom_ready(); Returns TRUE if the eeprom is ready ////
//// to receive opcodes ////
//// ////
//// The main program may define EEPROM_SDA ////
//// and EEPROM_SCL to override the defaults below. ////
//// ////
//// Pin Layout ////
//// ----------------------------------------------------------- ////
//// | | ////
//// | 1: NC Not Connected | 8: VCC +5V | ////
//// | | | ////
//// | 2: NC Not Connected | 7: WP GND | ////
//// | | | ////
//// | 3: NC Not Connected | 6: SCL EEPROM_SCL and Pull-Up | ////
//// | | | ////
//// | 4: VSS GND | 5: SDA EEPROM_SDA and Pull-Up | ////
//// ----------------------------------------------------------- ////
//// ////
///////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996, 2003 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
///////////////////////////////////////////////////////////////////////////
#ifndef EEPROM_SDA
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#endif
#define hi(x) (*((int8 *)&x+1))
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 4096
void init_ext_eeprom() {
output_float(EEPROM_SCL);
output_float(EEPROM_SDA);
}
BOOLEAN ext_eeprom_ready(int8 device_address) {
int1 ack;
i2c_start(); // If the write command is acknowledged,
ack = i2c_write(device_address); // then the device is ready.
i2c_stop();
return !ack;
}
void write_ext_eeprom(int8 device_address, long int address, BYTE data) {
while(!ext_eeprom_ready());
i2c_start();
i2c_write(device_address);
i2c_write(hi(address));
i2c_write(address);
i2c_write(data);
i2c_stop();
}
BYTE read_ext_eeprom(int8 device_address, long int address) {
BYTE data;
while(!ext_eeprom_ready());
i2c_start();
i2c_write(device_address);
i2c_write(hi(address));
i2c_write(address);
i2c_start();
i2c_write(0xa1);
data=i2c_read(0);
i2c_stop();
return(data);
}
|
_________________ Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Aug 17, 2017 8:01 am |
|
|
output_float(), with a single operation , shuts off any
input pullup within the chip for that pin and
leaves it in the TRIS=1 input receiver state........ |
|
|
Arakel
Joined: 06 Aug 2016 Posts: 107 Location: Moscow
|
|
Posted: Thu Aug 17, 2017 8:51 am |
|
|
asmboy wrote: | output_float(), with a single operation , shuts off any
input pullup within the chip for that pin and
leaves it in the TRIS=1 input receiver state........ |
Ok, thanks, dont kill me :D. _________________ Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 17, 2017 10:28 am |
|
|
output_float() does not shut off the internal pull-ups. It merely sets
the TRIS for the pin so it's equal to 1. This makes the pin into an input pin.
The 18F46K22 data sheet says, regarding internal pull-ups:
Quote: |
10.3.1 WEAK PULL-UPS
The weak pull-up is automatically turned off
when the port pin is configured as an output.
|
So it is output_low(), output_high(), and output_drive() that will disable
the internal pull-up. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Aug 17, 2017 10:45 am |
|
|
and if you think about it if you are driving something like an open collector bus, you want to drive it low only, or let it float high.
So you could set the output register to '0', then 'output_drive' would pull the line low, and 'output_float' would release the drive.
It really does do 'what it says on the tin'... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 17, 2017 10:50 am |
|
|
Quote: |
1. So "output_float" disregards what is on the pin? |
No. It makes the pin into an input pin.
Quote: |
2. On the pin we can have a grounded signal pulled by the external circuit
or a "1" meaning "5V" and the MCU will disregard both of them?
|
No. It becomes an input pin. It can then read a 0 or 1 state on it
that is created by an external circuit.
Quote: |
3. The "output_float" puts the pin in the high-impedance state, because
all pins can be "input, output, high-impedance", this is why they
are 3-state pins. |
The "high-impedance" state is the same as "input pin".
There is no difference. A pin that is input mode is automatically in
"high impedance" state.
Quote: | 4. The value is not recorded in "PORTA" but is recorded in "TRISA" ? |
You don't mean "recorded". You mean "set".
And yes, the TRISA register controls if a pin is input or output mode on PortA.
Quote: | 5. What is the "high impedance state" used for anyway? How much is this impedance? |
Input mode and "high impedance state" are the same thing !
Quote: | 6. Why not just leave the pin uninitialized? |
First, there is no uninitialized state. Upon power-on reset, all PIC pins
are put into input mode. This is done by the PIC chip itself. The compiler
doesn't control this.
Quote: | 7. When using this state with "EEPROM 2432", what exactly is it used for? |
The reason why the init_ext_eeprom() function exists is to put the pins
into the required mode for the 2432.c driver. It is possible that the
user may have set the pins as outputs, which will not allow the driver
to work. Calling init_ext_eeprom() is done to ensure that the pins are
in the correct mode for the driver, which is both SCL and SDA set as
input pins. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Aug 17, 2017 11:18 am |
|
|
It's worth understanding the multi-way nature of a pin on a PIC.
A pin can be set to drive high, drive low, or be undriven.
You can then read a pin, whether it is driven or not.
Now 'input', sets the pin to undriven, then reads it's state.
'Output' sets the pin to driven, and sets the output latch to drive in the selected direction.
'Input_state', leaves a pin either driven or undriven, and just reads it's state.
'Output_drive', leaves the output latch unchanged, and sets the pin to drive.
'Output_float', leaves the output latch unchanged and sets the pin to undriven. Doesn't read it.
Using 'output', then 'input_state', allows you to detect if a pin is overloaded (so not actually going to the selected level).
Using output_drive and output_float, allow you to turn the drive on/off without changing the output latch. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|