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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Adam Klaum
06/25/05 19:18
Read: 975 times


 
#95926 - Code I'm using
Responding to: Russell Bull'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        Adam Klaum      06/25/05 16:34      
   The logic seems good      Russell Bull      06/25/05 17:11      
      How to post code      Andy Neil      06/25/05 17:27      
      Code I'm using      Adam Klaum      06/25/05 19:18      
         Problem lies with SDCC and PSW handling.      Charles Bannister      06/26/05 00:09      
            similar "issue" with Keil?      Andy Neil      06/26/05 02:10      
            PSW not touched in recent version      Frieder Ferlemann      06/28/05 17:09      
               Old SDCC (ver ??) vs New SDCC (ver 2.50)      Charles Bannister      06/29/05 23:30      
                  strange      Frieder Ferlemann      06/30/05 00:35      
                     not strange, sorry      Frieder Ferlemann      06/30/05 04:24      
                        Still no good      Erik Malund      06/30/05 06:34      
                           Still not strange      Frieder Ferlemann      06/30/05 11:33      
   Alternative method      Jez Smith      06/26/05 01:13      
   65536, not 65535      Oleg Sergeev      06/27/05 00:31      
      Caught that errror      Adam Klaum      06/27/05 12:01      
         why not use the PCA, it is made for this        Erik Malund      06/27/05 12:07      
            No PCA available      Adam Klaum      06/27/05 23:21      
               slim PICkins      Russell Bull      06/28/05 02:13      
               go ahead, spend $7      Erik Malund      06/28/05 06:13      
                  Why not read 8051 stuff?      Jon Ledbetter      06/28/05 08:12      
                     Excellent - Thanks      Adam Klaum      06/28/05 09:22      
                  Atmel Flip      Adam Klaum      06/28/05 09:16      
                     MAX232(equivalent)      Erik Malund      06/28/05 09:23      
                        Another Option      Adam Klaum      06/28/05 15:46      
                     level convertor      Jan Waclawek      06/28/05 09:31      
                        aka "Transceiver"      Andy Neil      06/28/05 12:36      
         JSIM.EXE is all you need and it FREE.      Charles Bannister      06/27/05 12:36      
   Still not strange      Frieder Ferlemann      06/30/05 11:25      
   Follow Up to the original post      Adam Klaum      07/06/05 10:00      
      Dumb and dumberrer      Adam Klaum      07/07/05 18:56      

Back to Subject List