what wrong with this code?
Crosswinds
Posts: 182
Hello guys!
You probably have seen my other thread with different questions for my slotcar laptimer!
Well, i have this evening begin to dust of my spin-brain, so i have just played around a bit with it.
What Im trying to in this code, start 2 cogs, one that count 1 ms each cycle to a long, and another cog to present this value to the LCD display.
It works great when i dont assign Lane to a new cog, and just run it with passing it over to Lane. (but this aint going to cut it, since im going to have 4 different lane cogs running), and have the "present" running in its own cog.
But when it is in 2 different cogs, it counts to maybe 83 ms and then just freeze up.
Remember that this code does not reflect the finished idea, i just need to freshen up [noparse]:)[/noparse]
You probably have seen my other thread with different questions for my slotcar laptimer!
Well, i have this evening begin to dust of my spin-brain, so i have just played around a bit with it.
What Im trying to in this code, start 2 cogs, one that count 1 ms each cycle to a long, and another cog to present this value to the LCD display.
It works great when i dont assign Lane to a new cog, and just run it with passing it over to Lane. (but this aint going to cut it, since im going to have 4 different lane cogs running), and have the "present" running in its own cog.
But when it is in 2 different cogs, it counts to maybe 83 ms and then just freeze up.
Remember that this code does not reflect the finished idea, i just need to freshen up [noparse]:)[/noparse]
Comments
with this
If it works than you can make the 100 smaller until it works again.
In your 'present' function you call other functions of the LCD driver and you never know what these functions call themselves, maybe some private functions ... So, giving a stack of 9 longs simply is not enough and the function calls overwrite your millisec variable.
But another thing:
this is not accurate, as you always wait for 1ms + the execution time of all instructions.
Better is:
This way you always wait 1ms and the execution time of the instructions is no problem as long as it does not exceed the 1ms.
Post Edited (MagIO2) : 1/8/2010 11:21:56 PM GMT
And magIO2 thanks for the input about the wait time, that will help me to pinpoint accuracy [noparse]:)[/noparse]