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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/30/09 12:49
Read: times


 
Msg Score: -1
 -1 Off-Topic
#169302 - Timer 2 Interrupt Enable?
Hi all,
I am working with P89V664 micro-controller on SDCC. I want to configure Timer 2 in capture mode and generate interrupt on a H to L pulse. Here is the code:

#include <8052.h>

#define WAIT    1
#define READY   0
#define CLEAR   0
#define SET     1

volatile bit ovf = 0;   /* record the overflow */
volatile bit bit_status = READY;

void isr_byte_recv(void) __interrupt 7;

main()
{
        T2CON |= 0x01;
        EXEN2 = 1;
        EA = 1;
        ET2 = 1;
        TR2 = 1;
        while (1) {
                /* my application code here */
                /* This is a test code */
                if (TF2 == 1) {         /* check overflow */
                        P1_4 = !P1_4; /* LED1 */
                        TF2 = 0;
                }
        }
}


void isr_byte_recv(void) __interrupt 7
{
        P1_4 = !P1_4;
        if (TF2 == 1) {         /* check overflow */
                ovf = 1;
                P1_5 = !P1_5;   /* LED2 */
        }
        else
                P3_4 = !P3_4;   /* buzzer */
        TF2 = 0;
        EXF2 = 0;
}



Now, the LED 1,2 should toggle continuously and buzzer should beep when EXF2 is set. But I see only the led1 blinking and LED2 and Buzzer are OFF this indicates that the timer is configured for capture mode but not giving interrupts.

Is anything wrong here?



List of 3 messages in thread
TopicAuthorDate
Timer 2 Interrupt Enable?            01/01/70 00:00      
   Why the new thread?!            01/01/70 00:00      
      Duplicate Thread            01/01/70 00:00      

Back to Subject List