TIMER writing // LPC824

Questions about the BASICtools and MakeItC
Post Reply
olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

TIMER writing // LPC824

Post by olzeke51 »

Was checking some time for subroutines, attempted to reset your TIMER by writing to it.
[Your online Help says it can be written to]
It does not appear to start at the value given it - but at ?? (zero?)
Program delays seem to effect WAITMICRO(x) also.
Here is my code: (Timer=8000 or 18000)

Code: Select all

temp =TIMER
TIMER = 18000
temp1 =TIMER
waitmicro(10)
temp2=TIMER
'printing time not part of the issue
print temp
print temp1
print temp2
Here are the results:
========= TIMER= 8000
47518076' '( initial TIMER)
3

====== waitmicro(1) with TIMER=8000
255865943
3
8 ' TIMER after waitmicro(1)

====== wiatmicro(10) with TIMER = 18000
1022723' initial TIMER
3' * * * no change with a different TIMER=18000
17 ' TIMER after waitmicro(10) -- appears to be 10 microsecs increase over waitmicro(1)



TodWulff
Posts: 70
Joined: Fri Oct 19, 2012 4:03 am
Location: The Mitten State - Shores of Lake Huron

Re: TIMER writing // LPC824

Post by TodWulff »

Yep, I am too seeing this behaviour on the 824

Code: Select all

dim times(10) as integer

#define timer_reset_val 0x00004650

temp=timer
timer=timer_reset_val
temp1=timer
waitmicro(10)
temp2=timer

x=1
do
times(x)=timer
x+=1
until x=10

'printing time not part of the issue
print "init: ";temp
Print "Attempted to reset to: ";timer_reset_val
print timer_reset_val;"-ish?: ";temp1
print timer_reset_val;"-ish?: ";temp2

x=1
do
print x,times(x)
x+=1
until x=10

Results:

Code: Select all

Analyzing S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas
get addresses
 <= done

bpp.exe -DLPC824 -I"S:/_Dev/__My_Code/ARMbasic_Repo" -I"C:/Users/TAJS/Documents/_Dev/ARMbasic_libs/CoridiumBASICLibs_v937" "S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas" >C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
 Manual...
Compiling C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
ARMbasic[9.37m] on the PC  Copyright 2017, Coridium Corp.

... ( 0.26K code + 0.05K const)/18K   0.07/5K data programmed

compile done
Programming Flash *+*+
done
Executing...

Welcome to ARMbasic Kernel[8.40b] with Floating Point            Copyright 2017, Coridium Corp.
  for the LPC824    

Personal use copy for Beta Testing                                                                           
Commercial customers contact Coridium for licensing

init: 117936368
Attempted to reset to: 18000
18000-ish?: 3
18000-ish?: 17
1	20
2	24
3	28
4	31
5	35
6	39
7	43
8	47
9	57
 

... Finished in -117911 ms
Hmm. Seems to be present on the 54102 as well.

Code: Select all

Analyzing S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas
get addresses
stopButton
toggleReset
 <= done

bpp.exe -DLPC54102 -I"S:/_Dev/__My_Code/ARMbasic_Repo" -I"C:/Users/TAJS/Documents/_Dev/ARMbasic_libs/CoridiumBASICLibs_v937" "S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas" >C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
...
Compiling C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
ARMbasic[9.37m] on the PC  Copyright 2017, Coridium Corp.

... ( 0.26K code + 0.05K const)/416K   0.07/80K data programmed

compile done
Programming Flash *+*+
done
Executing...

init: 2569921
Attempted to reset to: 18000
18000-ish?: 2
18000-ish?: 13
1	13
2	14
3	15
4	16
5	18
6	19
7	20
8	21
9	22
 

... Finished in -2566 ms
Seems that any 'timer=blah' command simply resets it to zero on these targets (824/54102).?.

I just looked at the doc page for timer and it does say it is readable/writeable. But, maybe that is for pre-Cortex targets, where the timer wasn't reduced to 24-bit forcing an external register to be incremented to regain 32-bit timer functionality? Going to try on an ARMmite and edit this post.

EDIT: Yep, it works as expected on the LPC2103 (I had to change the waitmicro(10) to a wait(1) due to the old firmware on the ARMmite:

Code: Select all

Analyzing S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas
get addresses
stopButton
toggleReset
 <= done

bpp.exe -DLPC2103 -I"S:/_Dev/__My_Code/ARMbasic_Repo" -I"C:/Users/TAJS/Documents/_Dev/ARMbasic_libs/CoridiumBASICLibs_v937" "S:/_Dev/__My_Code/ARMbasic_Repo/GaryTimerTest2.bas" >C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
...
Compiling C:/Users/TAJS/AppData/Local/Temp/Coridium/GaryTimerTest2.bpp
ARMbasic[9.37m] on the PC  Copyright 2017, Coridium Corp.

... ( 0.39K code + 0.05K const)/16K   0.07/5K data programmed

compile done
Programming Flash *+*+
done
Executing...

init: 3725205
Attempted to reset to: 18000
18000-ish?: 18000
18000-ish?: 19000
1	19001
2	19002
3	19003
4	19005
5	19006
6	19007
7	19009
8	19010
9	19011
 

... Finished in -3626 ms
As such, I perceive we have an 'it is what it is...' case and should know that one can only reset the timer to zero via a timer=blah construct on ARMbasic Cortex Targets until such time as Bruce updates the compiler/firmware.

Post Reply