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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/26/05 01:18
Read: times


 
#95926 - Code I'm using
Responding to: ???'s previous message
Russel, thanks for the quick reply! Below is the latest iteration of my code. Thanks for the kudos Andy! I try to be thorough.

Code:


#include <at89x51.h>

#define ON 1
#define OFF 0
#define HIGH 1
#define LOW 0

void Timer0_ISR (void) interrupt 1;	// ISR for Timer0 overflow

void Timer0_ISR (void) interrupt 1
{
    if(F0 == LOW) {  /* Just finished the LOW period, switching to HIGH */
        F0 = HIGH;
        P1_0 = OFF;  /* Turning on P1_0 */
        TH0 = 0xFA;  /* Setting timer start value to 64245 */
        TL0 = 0xF5;
        TF0 = 0;     /* Reset Timer Overflow Flag */
    }

    else {           /* Just finished the HIGH period, switching to LOW */
        F0 = LOW ;
        P1_0 = ON;   /* Turning off P1_0 */
        TH0 = 0xC3;  /* Setting initial timer value to 50068  */
        TL0 = 0x94;
        TF0 = 0;     /* Reset Timer Overflow Flag */
    }

    return;
}

void main (void)
{
    EA = ON;       /* Enabling All Interrupts */
    ET0 = ON;      /* Enabling Timer 0 Interrupt */

    TR0 = 0;       /* Stop Timer 0 */
    TF0 = 0;       /* Reset Timer Overflow flag */

    TMOD &= 0xF0;  /* Set Timer 0 to Mode 1 (16-bit no prescalar) */
    TMOD |= 0x01;  /* Set Timer 0 to Mode 1 (16-bit no prescalar) */

    TH0 = 0xC3;    /* Setting initial timer value to 50068 (i.e. LOW period) */
    TL0 = 0x94;

    F0 = HIGH;     /* Setting F0 Flag to HIGH */

    P1_0 = OFF;    /* Turning off P1_0 */

    TR0 = 1;       /* Starting Timer 0 */

    while (1)
    {
    }
}



List of 30 messages in thread
TopicAuthorDate
General Pulse Width Modulation on 8051            01/01/70 00:00      
   The logic seems good            01/01/70 00:00      
      How to post code            01/01/70 00:00      
      Code I'm using            01/01/70 00:00      
         Problem lies with SDCC and PSW handling.            01/01/70 00:00      
            similar "issue" with Keil?            01/01/70 00:00      
            PSW not touched in recent version            01/01/70 00:00      
               Old SDCC (ver ??) vs New SDCC (ver 2.50)            01/01/70 00:00      
                  strange            01/01/70 00:00      
                     not strange, sorry            01/01/70 00:00      
                        Still no good            01/01/70 00:00      
                           Still not strange            01/01/70 00:00      
   Alternative method            01/01/70 00:00      
   65536, not 65535            01/01/70 00:00      
      Caught that errror            01/01/70 00:00      
         why not use the PCA, it is made for this            01/01/70 00:00      
            No PCA available            01/01/70 00:00      
               slim PICkins            01/01/70 00:00      
               go ahead, spend $7            01/01/70 00:00      
                  Why not read 8051 stuff?            01/01/70 00:00      
                     Excellent - Thanks            01/01/70 00:00      
                  Atmel Flip            01/01/70 00:00      
                     MAX232(equivalent)            01/01/70 00:00      
                        Another Option            01/01/70 00:00      
                     level convertor            01/01/70 00:00      
                        aka "Transceiver"            01/01/70 00:00      
         JSIM.EXE is all you need and it FREE.            01/01/70 00:00      
   Still not strange            01/01/70 00:00      
   Follow Up to the original post            01/01/70 00:00      
      Dumb and dumberrer            01/01/70 00:00      

Back to Subject List