I2C use slows other tasks ?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

I2C use slows other tasks ?

Post 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
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: I2C use slows other tasks ?

Post 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.
- Don Kinzer
Post Reply