Another Question: strange behavior of timer
ErNa
Posts: 1,752
I'm developing a control software which runs a timer:
A second propeller does the UI with screen and buttons.
There is a communication in between in a very early stage of development, so there might be bugs like overflow, write unintended to memory etc.
Every second this timer changes the offset value and this value is transfered to the UI.
Normally that works fine, but it may happen, that the timer runs much faster than one second (about ten times :-( ) and then stops for about 27 seconds like this is the case with a counter overflow.
Is there a way to unintended write to the counter? Or could it be that the value of ClkFreq is corrupted?
Up to now I did not find a way to stimulate the behavior, so I am in a very early stage of debugging, anyway the software needs a revision, as the communicator has to be merged with the serial IO to save a cog.
if (ttimer - cnt) < 0 ttimer += ClkFreq testoffset := ( testoffset // 9000 ) + 1000This code runs on one propeller in parallel to other processes, like full duplex serial, stepper driver etc.
A second propeller does the UI with screen and buttons.
There is a communication in between in a very early stage of development, so there might be bugs like overflow, write unintended to memory etc.
Every second this timer changes the offset value and this value is transfered to the UI.
Normally that works fine, but it may happen, that the timer runs much faster than one second (about ten times :-( ) and then stops for about 27 seconds like this is the case with a counter overflow.
Is there a way to unintended write to the counter? Or could it be that the value of ClkFreq is corrupted?
Up to now I did not find a way to stimulate the behavior, so I am in a very early stage of debugging, anyway the software needs a revision, as the communicator has to be merged with the serial IO to save a cog.
Comments
If you want something to happen every 100ms you might do this:
Anyway, I know that my communication routine can be asynchronous and so get a wrong destination address, so I write data to an arbitrary place. That has to be fixed.
Thanks for contributions!
The ClkFreq value is stored at HubRAM location 0..3. If some code overwrites this locations you get a wrong value when you use ClkFreq.
Because all variables are initialized with 0, the chance to overwrite at this address is high, if a wrong pointer variable is used or you forget a @ to specify the address, or something like that.
Andy