Hi, my name is hardian and i have some problem with setting timer as counter, and i already wrote a code : TR0=1; TMOD=0x06; ET0=1; EA=1; but it still doesnt work, can anyone tell me how to set it? sincerly, hardian
Hardian, Your code is working, you can see it working with your debuger. Take a look at the gererated assembly code and you'll notice that the first instruction is running the Timer0 as a 13-Bit Timer because of the TMOD reset value 0x00h, so to avoid future problems always configure whatever you need before turn the things on. Here's your gererated code:
0000 D28C SETB TR0 0002 758906 MOV TMOD,#06H 0005 D2A9 SETB ET0 0007 D2AF SETB EA
... TMOD= 0x06; TH0 = recharge_value; TL0 = inicial_value; ET0 = 1; EA = 1; TR0 = 1;
void counter0 ( void ) interrupt 1 using 2 { ... }