| ??? 01/18/05 22:30 Read: times |
#85256 - Simultaneous example Responding to: ???'s previous message |
Instructions on how to post code:
http://www.8052.com/forum/read.phtml?id=82476 OK, so I've suggested driving all three simultaneously three times now: http://www.8052.com/forum/read.phtml?id=85114 http://www.8052.com/forum/read.phtml?id=85171 http://www.8052.com/forum/read.phtml?id=85195 Perhaps an example would help: // Your original Port bit definitions
sbit ibutton_io_1 = 0xA0; // P2.0 – Read 1
sbit ibutton_io_2 = 0xA2; // P2.2 – Read 2
sbit ibutton_io_3 = 0xA4; // P2.4 – Read 3
// Bit-addressable buffer for the 1-Wire lines
unsigned char bdata ow_buf;
// Inidividual bits in the buffer
// Note that these bit positions must match the Port bit positions!
sbit ow_buf_1 = ow_buf^0;
sbit ow_buf_2 = ow_buf^2;
sbit ow_buf_3 = ow_buf^4;
//*****************************************************************
// OW_RESET
// Function description:
// Performs a reset on all three one-wire busses and returns the
// presence pulses detected in the global bit-addressable buffer 'ow_buf'.
//
// When the function returns, the Presence Pulse values are in
// the buffer bits:
// 1 indicates no presence pulse on the corresponding line;
// 0 indicates a presence pulse on the corresponding line.
//
// Reset is 480us, so delay value is (480-24)/16 = 28.5 - we use 29.
// Presence 70us later, so delay is (70-24)/16 = 2.875 - we use 3.
//
// Return value: None
// *****************************************************************
void Ow_Reset(void)
{
ibutton_io_1 = LOW; // pull 1-Wire line 1 low
ibutton_io_2 = LOW; // pull 1-Wire line 2 low
ibutton_io_3 = LOW; // pull 1-Wire line 3 low
uDelay(29); // leave them all low for 488us
ibutton_io_1 = HIGH; // allow line 1 to return high
ibutton_io_2 = HIGH; // allow line 2 to return high
ibutton_io_3 = HIGH; // allow line 3 to return high
uDelay(3); // wait for presence 72us
// Sample each line for a Presence Pulse
ow_buf_1 = ow_io_1; // Read 1-Wire line 1
ow_buf_2 = ow_io_2; // Read 1-Wire line 2
ow_buf_3 = ow_io_3; // Read 1-Wire line 3
uDelay(?); // wait for 410us (the remainder of the timeslot)
} Notes:
|
| Topic | Author | Date |
| sbit | 01/01/70 00:00 | |
| I do not understand | 01/01/70 00:00 | |
| You mean Dallas 1-Wire? | 01/01/70 00:00 | |
| Re | 01/01/70 00:00 | |
| What's the problem? | 01/01/70 00:00 | |
| I think that... | 01/01/70 00:00 | |
| indirect bit addressing | 01/01/70 00:00 | |
| The same iButton on all 3? | 01/01/70 00:00 | |
| sbit | 01/01/70 00:00 | |
| access all 3 , one at a time | 01/01/70 00:00 | |
| I had the same problem | 01/01/70 00:00 | |
| Lets try again | 01/01/70 00:00 | |
| Need ? | 01/01/70 00:00 | |
| Why? | 01/01/70 00:00 | |
| There is always the switch statement | 01/01/70 00:00 | |
| something like this... | 01/01/70 00:00 | |
| Simultaneous example | 01/01/70 00:00 | |
| Use MASK rather than bit address | 01/01/70 00:00 | |
| Oooops, sorry... | 01/01/70 00:00 | |
| Multiple 1Wire | 01/01/70 00:00 | |
| How to post code, and possible hang-up | 01/01/70 00:00 | |
| simultaneous? | 01/01/70 00:00 | |
| would even be better | 01/01/70 00:00 | |
If it worked! | 01/01/70 00:00 |



