Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/30/03 11:10
Read: times


 
#61568 - RE: RTC Assembly and C
Responding to: ???'s previous message
hi gerry,

there might be an alternative to including asm in the c code.

What i am suggesting is initialization of the timer in a function which will serve as the ISR. I have used "initialization", but what i mean is re-init, assuming that you are operating the timer in mode 1 (16-bit up counter). in this function update a user defined bit.

then in the main function you'd have probably included an infinite loop. just insert an if statement checking if that userflag is set. if it is then update your time (i.e. sec, min, hours etc...) in another function that you can call from that location.

i have not used keil C, but i use SDCC so here's my soultion. maybe you could port it to Keil an check it out. (at least the logic should remain the same)


#include <8051.h>

bit flag = 0;

void timer_0_isr(void) interrupt 1 using 1
{
TCON.4 = 0;
TH0 = 0xfc; /* i have inserted radom values you'll have to calculate your values. i recomend adjusting it to around 1ms if possible*/
TL0 = 0xdd;
flag = 1;
TCON.4 = 1;
}

void increment(void)
{
/*add you RTC procedure here*/
}

void main(void)
{
while(1)
{
if(flag == 1)
{
flag = 0;
increment();
}
}
}


cheers and wish you a very happy new year,

Sushil Siddesh

List of 7 messages in thread
TopicAuthorDate
RTC Assembly and C            01/01/70 00:00      
   RE: RTC Assembly and C            01/01/70 00:00      
   RE: RTC Assembly and C            01/01/70 00:00      
      RE: RTC Assembly and C            01/01/70 00:00      
   RE: RTC Assembly and C            01/01/70 00:00      
      RE: RTC Assembly and C            01/01/70 00:00      
      asm relapse!!            01/01/70 00:00      

Back to Subject List