READTEMP messing with TIME

SD2100

New Member
Have problem with the TIME variable not incrementing once per second when the READTEMP command
is in use. When READTEMP is remmed out the value of TIME is sent to the PC once per second but when
READTEMP is enabled the TIME variable is only being updated approx every 30 seconds. READTEMP takes
about 750mS to execute so this should affect the sending of TIME every second. I thought the TIME counter
was a separate counter on the chip that just started and ran at power up and could be read at any time
to check ellapsed seconds.

Code:
#Picaxe 08m2
#No_Data
do
    readtemp C.2,b5
    if w3 <> Time then
        w3 = Time
        BINTOASCII Time, b4, b3, b2, b1, b0
        sertxd (b4, b3, b2, b1, b0,13,10)
    end if	
loop
Chip version 4.A
PE 5.4.3
 

hippy

Ex-Staff (retired)
I thought the TIME counter was a separate counter on the chip that just started and ran at power up and could be read at any time to check ellapsed seconds.
There are two parts to the 'time' variable operation. An internal hardware timer that generates ticks and part of the firmware which checks for ticks, counts them and increments the 'time' variable so it increments at a rate of once per second.

When the PICAXE executes READTEMP the hardware timer keeps running, keeps giving ticks but the firmware is busy dealing with the DS18B20 so does not see or count those ticks.
 

SD2100

New Member
There are two parts to the 'time' variable operation. An internal hardware timer that generates ticks and part of the firmware which checks for ticks, counts them and increments the 'time' variable so it increments at a rate of once per second.

When the PICAXE executes READTEMP the hardware timer keeps running, keeps giving ticks but the firmware is busy dealing with the DS18B20 so does not see or count those ticks.
Thanks hippy

I thought the timer might have it's own 16 bit register that it incremented once per second and then could be read when needed, instead it's just a ticker that
has to be constantly monitored and counted so it's easily lost track of with firmware holdups etc. I would have looked at the datasheet to see what it was but
couldn't find one..
 

MartinM57

Moderator
I thought the TIME counter was a separate counter on the chip that just started and ran at power up and could be read at any time
to check ellapsed seconds.
It would be fantastic if it was - but, IMHO and in its current form, it's pretty severely limited for doing anything useful except in the most simplistic programs.

I wonder if there's a different firmware implementation possible that would make it like everyone wants it to be?
 

hippy

Ex-Staff (retired)
I thought the TIME counter was a separate counter on the chip that just started and ran at power up and could be read at any time to check ellapsed seconds.
It would be fantastic if it was - but, IMHO and in its current form, it's pretty severely limited for doing anything useful except in the most simplistic programs.
How limited really depends on what one wants to do and some quite complicated programs can use it satisfactorily.

I wonder if there's a different firmware implementation possible that would make it like everyone wants it to be?
Unfortunately not. To be perfect in all circumstances it needs a timer which can deliver a 16-bit value which increments every second, and there isn't such a thing, so it has to be a hardware and software solution. And on a single chip system you can't do two software things at once and something has to give.

I would have looked at the datasheet to see what it was but
couldn't find one..
Chip datasheets are here ...

http://www.picaxe.com/What-is-PICAXE/PICAXE-Chip-Labels/

But those won't necessarily tell you how the system and associated firmware is actually implemented and it is often not how people may imagine it to be.
 

SD2100

New Member
I wonder if there's a different firmware implementation possible that would make it like everyone wants it to be?
According to hippy it's just a ticker that the firmware has to count so your always going miss counts here and there, it needs it's own register.
You would think if their going to put a timer/counter on the chip it would have some sort of register that increments on each tick then rolls over
and starts again, thats what I thought it was...
 
Top