GP32 Rtc In Mr.mirko Sdk


pea

developer
Joined
Oct 3, 2004
Messages
1,089
Age
46
Location
New Zealand
Website
www.projectitis.com
Hi all,

I recall this being covered many moons ago, but can't seem to find the post.

I would like to change the RTC (Mr.Mirkos SDK) from 1/64 second to 1/32 second but can't recall the logic to do this. The current code is:

Code:
void setupRTCInt( void ) {
   // enable RTC
   rCLKCON |= 0x800;
   //
   // The CPU clock indepentent RTC Timer
   //
   // The ticnt register 0x15700044 (32 bit) offers:
   //
   // BIT   7: 0=disable 1=enable timer
   // BIT 0-6: tick time count value 1-127
   //
   // %10000000 should result in a 1/128 timer, but is not working
   // %10000001 result in 1/64 timer
   // %11111111 result in 1/1  timer
   
   rTICINT = 0x81;
   rGLOBALCOUNTER = 0;
}

Would I be correct in thinking:
Code:
   // %10000000 should result in a 1/128 timer, but is not working
   // %10000001 result in 1/64 timer

   // %10000011 result in 1/32  timer
   // %10000111 result in 1/16 timer
   // %10001111 result in 1/8 timer
   // %10011111 result in 1/4 timer
   // %10111111 result in 1/2 timer

   // %11111111 result in 1/1  timer
?

Aha, found the wayward post:

According to squidge:
( value + 1 ) / 128 second

therefore (also adding the 8th bit)
value = (128/t)+127;
where t = number of times per second to fire

So for 1/32 seconds (32 times per second)
value = (128/32)+127;
value = 131; // %10000011 or 0x83
 
pea posted on Aug 23 2005 at 09:34 AM said:
Would I be correct in thinking:
Code:
   // %10000000 should result in a 1/128 timer, but is not working
   // %10000001 result in 1/64 timer

   // %10000011 result in 1/32  timer

I'd say the value is a divider ... so 1/32 would be:

%10000010 result in 1/32 timer

But frankly; I'd write a wrapper fonction doing.. way more easy :)

unsigned long myRTC() {
return getRTC()>>1 ;
} ;
 
Last edited by a moderator:
Back
Top