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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/20/05 20:13
Read: times


 
#92014 - DS89C450 / uVision2, timer0 trouble
Hello All,

I've run into some problems while trying to implement a simple delay-routing on my DS89C450. After having peeked into various application notes and having tried out the code therein with no immediate success, I ventured on to my current, rather simple approach.
Below you will find my source code - I hope I am not offending anyone by posting it in the message - and the problematic part is that when it is flashed into the micro, the if-statements determining the current time and incrementing seconds, minutes and hours are left untouched, whereas in the simulator they work.

/Thomas

#include <REG420.H>

char timer0_tick;
int secs,mins,hrs;

void timer0_isr(void) interrupt 1
{
timer0_tick++;
P1 ^= 0x80;

return;
}

void timer0_initialize(void)
{
EA = 0; /* disable interrupts */
TMOD = (TMOD & 0xF0) | 0x01; /* Set T/C0 Mode */
CKCON = (CKCON & ~0x03); /* Select external oscillator as source */
CKMOD = (CKMOD & ~0x03); /* Select external oscillator as source */
TMOD = (TMOD & ~0x02); /* Select external oscillator as source */
ET0 = 1; /* Enable Timer 0 Interrupts */
TR0 = 1; /* Start Timer 0 Running */
EA = 1; /* enable interrupts */

return;
}

void init(void)
{
timer0_tick = 0;
timer0_initialize();

secs, mins, hrs = 0;
P0 = P1 = P2 = P3 = 0x00;

return;
}

void main(void)
{
init();

while(1)
{
if(timer0_tick == 14) { secs++; timer0_tick = 0; P1 ^= 0x01; }
if(secs == 60) { secs = 0; mins++; P1 ^= 0x02; }
if(mins == 60) { mins = 0; hrs++; P1 ^= 0x04; }
if(hrs == 24) { hrs = 0; P1 ^= 0x08; }
}
}


List of 33 messages in thread
TopicAuthorDate
DS89C450 / uVision2, timer0 trouble            01/01/70 00:00      
   perhaps            01/01/70 00:00      
      nope - didn't work            01/01/70 00:00      
   never used Dallas but            01/01/70 00:00      
      I just followed orders            01/01/70 00:00      
         link, please            01/01/70 00:00      
            my apologies            01/01/70 00:00      
               try system clock            01/01/70 00:00      
                  The system clock vs. External Oscillator            01/01/70 00:00      
                     Try >=?            01/01/70 00:00      
                        good idea            01/01/70 00:00      
                           probably a watchdog or such            01/01/70 00:00      
                              about the beer ...            01/01/70 00:00      
                                 reason            01/01/70 00:00      
                                    puzzled by the simplicity            01/01/70 00:00      
                                       It's getting late in Denmark            01/01/70 00:00      
                                          the Thomas Skyt late night show ...            01/01/70 00:00      
                                             kiss            01/01/70 00:00      
                                                KISS/2            01/01/70 00:00      
   A variety of thoughts            01/01/70 00:00      
      A variety of answers            01/01/70 00:00      
         Thoughts for variety of answers            01/01/70 00:00      
            sfr's            01/01/70 00:00      
            the watchdog            01/01/70 00:00      
               The watchdog, timed access, and errata            01/01/70 00:00      
                  setting the OCR to disable the watchdog            01/01/70 00:00      
                     Timed access, take 2            01/01/70 00:00      
                        unnecessary excersize            01/01/70 00:00      
                           The watchdog, take 3            01/01/70 00:00      
                              when in doubt            01/01/70 00:00      
                                 Examining the assembly            01/01/70 00:00      
                                    get out of there            01/01/70 00:00      
                                       I got out, found a solution            01/01/70 00:00      

Back to Subject List