Hello, I have an interesting problem with the TWI in the at91sam7s64. I am trying to detect the absence of a device on the TWI bus. I had expected to receive a NACK in the status register upon sending the device address. Insted I received 0xFF data back and no error in the twi_sr. 1) is there something I am missing. 2) is there a correct procedure for detecting the absence of a device on the bus. I was planing to use this feature (normaly available on I2C) to implement module detection. Regards Peter -- Peter Wintulich VoiceTronix Powering Open Telephony Ph . +61 8 8232 9112 Fax. +61 8 8232 9113 www.voicetronix.com.au
Detecting absence of I2C bus devices
Started by ●January 18, 2006
Reply by ●January 18, 20062006-01-18
I would think the answer to this may be in the data sheet for the external device you are talking to. Does that device data sheet indicate it sends the NACK? Further I think it is a job for a logic analyser where you can capture the bit pattern going and coming. A picture is worth a thousand words. You can buy low cost usb analysers... Look for ANT-16, etc. Al Welch -----Original Message----- From: AT91SAM@AT91... [mailto:AT91SAM@AT91...] On Behalf Of Peter Wintulich Sent: Wednesday, January 18, 2006 7:46 AM To: AT91SAM@AT91... Subject: [AT91SAM] Detecting absence of I2C bus devices Hello, I have an interesting problem with the TWI in the at91sam7s64. I am trying to detect the absence of a device on the TWI bus. I had expected to receive a NACK in the status register upon sending the device address. Insted I received 0xFF data back and no error in the twi_sr. 1) is there something I am missing. 2) is there a correct procedure for detecting the absence of a device on the bus. I was planing to use this feature (normaly available on I2C) to implement module detection. Regards Peter -- Peter Wintulich VoiceTronix Powering Open Telephony Ph . +61 8 8232 9112 Fax. +61 8 8232 9113 www.voicetronix.com.au Yahoo! Groups Links
Reply by ●January 22, 20062006-01-22
--- In AT91SAM@AT91..., "Al Welch" <alwelch@a...> wrote: > > I would think the answer to this may be in the data sheet for the external > device you are talking to. ... You lost me on that one, Al. I don't know the answer to Peter's question, but he is trying to determine the response from a device-- that is not there. I don't see how the datasheet of a non-existent/non- present device has any bearing on the issue. I wouldn't expect to see a notation: "When this device has not been purchased and is not attached to your application, it will not respond to requests." Or maybe I'm misreading the issue. Lee
Reply by ●January 22, 20062006-01-22
Lee, I must have missed something in his original post as I thought he was trying to get an external device to respond. That being what I thought he was doing prompted me to suggest what I did post. I do not think you needed to make any remarks about a non existant device responding as clearly that was not what I was talking about. Maybe my post made him think about needing a device in order to get a response if he did not have one there. I guess I will read his post closer. Al -----Original Message----- From: AT91SAM@AT91... [mailto:AT91SAM@AT91...] On Behalf Of budfrog99 Sent: Saturday, January 21, 2006 7:43 PM To: AT91SAM@AT91... Subject: [AT91SAM] Re: Detecting absence of I2C bus devices --- In AT91SAM@AT91..., "Al Welch" <alwelch@a...> wrote: > > I would think the answer to this may be in the data sheet for the external > device you are talking to. ... You lost me on that one, Al. I don't know the answer to Peter's question, but he is trying to determine the response from a device-- that is not there. I don't see how the datasheet of a non-existent/non- present device has any bearing on the issue. I wouldn't expect to see a notation: "When this device has not been purchased and is not attached to your application, it will not respond to requests." Or maybe I'm misreading the issue. Lee Yahoo! Groups Links
Reply by ●January 22, 20062006-01-22
Lee, I re-read the post and I can see where you were coming from. I presumed he had a device that was not responding with what he epected it to. Al --- In AT91SAM@AT91..., "budfrog99" <lee_h_theusch@h...> wrote: > > --- In AT91SAM@AT91..., "Al Welch" <alwelch@a...> wrote: > > > > I would think the answer to this may be in the data sheet for the > external > > device you are talking to. ... > > You lost me on that one, Al. I don't know the answer to Peter's > question, but he is trying to determine the response from a device-- > that is not there. I don't see how the datasheet of a non- existent/non- > present device has any bearing on the issue. I wouldn't expect to see > a notation: "When this device has not been purchased and is not > attached to your application, it will not respond to requests." > > Or maybe I'm misreading the issue. > > Lee >
Reply by ●January 23, 20062006-01-23
Hello, I have worked out the sloution. Using the status register return values you can detect if an addressed device is absent. Using a Read for 1 byte: In IDLE the status register is 0x000d On issuing a Start|Stop, the status reg. reads 0x000e If No device matching the I2C address is Present, then the status goes back to IDLE 0x000d without any data or NACK flags being set. If the device is present then the status register returns 0x000e indicating the TWI_RHR is full, when the TWI_RHR is read the status returns to IDLE. I have only tested this for single byte reads. I found that when I had not set the Stop flag in the control reg. I recived a byte back of 0xff, and also had instances of the Overflow flag being set. This would sudgest that it won't work for the multi byte transfer mode. This would need further testing to prove the behaviour. For now the single byte read responce will do what I need. If the request goes back to IDLE before reciving the data byte I can interpret this as a NACK in the address cycle. Regards Peter