You need to log in to create posts and topics.

Timers and Internal interruptions on C51

Hi,

I've got som trouble while programming in C51 the atmel 8051 uC. When it comes to using timers, I am not able to jump into the interruption, i am not sure if the simulator is able to simulate interruptions of timers overflow:

#include <reg51.h>	

sbit Tuds=P2^1;
sbit Tdec=P2^2;
sbit Tcent=P2^3;
unsigned int cont_interrupt;

void delay_ms(unsigned int ms){
    unsigned int i;
    unsigned char j;

    for(i=1; i<ms; i++)
    {
        for(j=1; j<126; j++)
        {
        }
    }
}

void visualizacion(unsigned int number){
    unsigned char decena;
    unsigned char unidad;
    unsigned char centena;

    unidad=number%10;
    decena=(number/10)%10;
    centena=(number/100)%10;

    P2 = unidad|0x20 ;
    delay_ms(5);

    P2 = decena|0x40;
    delay_ms(5);

    P2 = centena|0x10;
    delay_ms(5);
}

void RSI_tempo() interrupt 1{
		TH1=0xD8;
        TL1=0xF0;//10000us=10us=0.01s
        cont_interrupt+=1;
}

void main(){
    IE=0x8A;
    TMOD=0x15; //0001 0101 de esta manera el timer 0 esta como contador de eventos y el timer 1 como temporizador
    //Configuraion del timer 1 como temporizador
    TH1=0xD8;
    TL1=0xF0;//10000us=10us=0.01s
    
    //configuracion del timer 0 como contador de eventos
    TH0=0x00;
    TL0=0x00;
    
	TR1=1;
	TR0=1;
	cont_interrupt=0;

    P2=0x00;

    while(1){
			if (cont_interrupt == 1000){
                cont_interrupt=0;
                visualizacion(123);
            }
    }
}

 

The circuit is the microcontroler with a multiplexed seven segment using a bcd to seven segment decoder.

 

Some help would be gratefull 🙂

Hi, thanks for reporting.

It's important to know which version of simulide are you using.

And I can't test your code, no idea which compiler is that and no .hex and circuit files.

The simulator can simulate interrupts.