This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem using timer interruptions

Hi. I'm having a problem with a very simple code. When I run it with te computer using Keil it works fine, but when I send it to the micro controller it doesn't work. I don't think it's the device that I'm using to send the program to the controller, because it works fine when i send a similar code in assembly language. The problem is when i use C. Here is the code:


#include <REGx52.H>

void seteo_inicial (void);

int main (void){
        seteo_inicial ();
        while (1){
                ACC=1;
        }
        return 1;
}

timer0_int () interrupt 1{
        TR0=0;
        TR1=0;
        TH0=0xfb;
        TL0=0x00;
        TL1=0x00;
        TH1=0xfd;
        P2=0xff;
        TR1=1;
        TR0=1;
}

timer1_int () interrupt 3{
        TR1=0;
        P2=0x00;
}

void seteo_inicial (void){
        P2=0x00;
        IP=0x22;
        TR0=0;
        TR1=0;
        IE=0xaa;
        TMOD=0x11;
        TH0=0xfb;
        TL0=0x00;
        TR0=1;
}

The port 2 should be changing its value from 0x00 to 0xff continuously, but this isn't the case, and i don't know why. Can someone help me with this?

Thanks
Tomas

Parents Reply Children
  • The OP also fails to realize that when we see comments, we can point out where the expectations of the comments doesn't match the results of the source lines.

    Just looking at a number of assigns, I'm not really likely to care what the lines does which means the OP will spend his time with out responses.