|
|
| Author |
Message |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 19 January 2006, 0:54 AM Post subject: New Application Note - Sharing Data Between Tasks |
|
|
There is a new application note available describing some techniques for safely sharing data between tasks.
AN210 Sharing Data Between Tasks
Last edited by dkinzer on 25 January 2007, 23:16 PM; edited 1 time in total |
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
Posts: 664
|
|
Posted: 19 January 2006, 20:26 PM Post subject: Re: New Application Note - Sharing Data Between Tasks |
|
|
This is a great note on a surprisingly non-intuitive subject.
Just yesterday this issue hit me between the eyes. I was doing some interrupt driven data transmission (over some I2C hardware). I would fill a buffer then start the transmission, then move on to the next data. I would then transmit this one.
I thought that I had told the transmission routine to be sure that the last one was done before it started the next. And I did.... But....
I was filling the buffer before I did the check. Unfotunately, this buffer was also being used to transmit the data! I had sidestepped using a buffer of my own in addition to the transmit buffer in order to save RAM. I just interracted directly with the transmit buffer.
I couldn't understand why the FIRST data write worked, and all the data reads worked, but none of the data writes that happened sequentially after the first. The read functions did reliably wait for the system to go idle.
After checking everything else, I suddenly realized that I was corrupting the data buffer!
I simply added a check of the flag showing a transmission was in progress and the problem was solved. I wasted a lot of time on that one.
Excellent Appnote.
-Tony |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX
|
|
Posted: 19 January 2006, 20:38 PM Post subject: |
|
|
Thanks for the feedback. It's always nice to get it - positive or negative.
I have wanted to write something like this for BasicX but never quite got to it. Now I have finally. I'm also in the process to doing some changes so that it can be also used by BasicX users. |
|
| Back to top |
|
 |
|