From: Lawrence H. <gumstix@HariTech.com> - 2008-03-10 23:37:11
|
Justin, I don't know this code but in general calling a function that requires and interrupt to complete from within and interrupt service routine is often a problem. Interrupts are typically disabled within the ISR you can find yourself waiting forever. There are I/O systems that can nest interrupts but most simple embedded systems don't get that complex. If for example you are trying to write the pulse width from the ultrasonic sensor to a flash memory address you should read it first, then call the I2C routines to write the data. The I2C ISR routine is probably only supposed to supply the next bye from the buffere being written or go idle if no more data is available. ISR's generally are suppose to be short and sweet with nothing that might cause a block or delay. Lawrence Justin Rajewski wrote: > I just though of something. Since the I2C on the robostix is an interrupt > would using an interrupt inside of it (the ultrasonic command) cause the > robostix to not be able to call the interrupt, making it freeze at > ultra_pulse->pulse = ultrasonic(); > and then the gumstix does not get a reply so it times out? > > One more thing. The pulse from the ultrasonic sensor can be up to 18.5ms for > a total time of about 20ms to read from it. Could this be a problem? > > I can tell the command gets send as the LED on the sensor flashes. > > Justin > |