Page 1 of 1

I2C use slows other tasks ?

Posted: 19 August 2011, 14:31 PM
by FFMan
I have a small problem with my GPS based qualifying light. Its secondary purpose is to write GPS records to an serial sd card modle at 10hz. Upon analysis i see occasional missing records and these seem to coincide with the main task processing a sector cross event which occur every 3 seconds or so.

The code triggered upon sector cross doesn't amount to much, but does involve updating the LCD (using zbasic I2C functions on s/w pins) in 4 places and i wonder if the I2C routines might cause a suspend of the GPS read sub-task ?

I can alter the display interface to be serial in the next version and i wonder if this might be more efficient as the serial output would not require any flow control. Alternatively I could use h/w I2C in the next version as the processor has more pins.

thanks

Re: I2C use slows other tasks ?

Posted: 21 August 2011, 16:06 PM
by dkinzer
FFMan wrote:i wonder if the I2C routines might cause a suspend of the GPS read sub-task ?
The I2C routines do not suspend other tasks. However, for a VM-based device, a task switch will not occur until the I2C instruction finishes. (The VM only switches tasks at VM instruction boundaries, never in the midst of an instruction.) In contrast, for a native mode device, a task switch can occur at machine instruction boundaries, a much finer granularity, provided that interrupts are not disabled. This last point is important if you're using the software-implemented I2C channels because interrupts are disabled for the duration of each byte sent or received.