@JohnInTX I am trying to simulate behavior of timer0 & mode1
1 tick take 1.085 us
100 * 1.085 = 108.5 us
65535 - 100 = 65435 ( 1111111110011011)
TH0 = 0xFF
TL0 = 0x9B
Timer will overflow at every 108.5 us
Program suppose to toggle port2 pin0 at each timer overflow
C:
#include<reg51.h>
sbit PIN = P2^0;
void main (void) // Program start
{
P0 = 0;
P1 = 0;
P2 = 0;
P3 = 0;
TMOD = 1; //Timer mode1
TH0 = 0xFF;
TL0 = 0x9B;
TR0 = 1; // Start timer0
TF0 = 0; // clear timer overflow flag
while(1)
{
if (TF0 == 1) // check Timer0 overflow flag
{
PIN =~ PIN; // Toggle PIN P2^0 //
TF0 = 0; // clear Timer0 overflow flag
TH0 = 0xFF;
TL0 = 0x9B;
}
}// while
}//main
Attachments
-
237.7 KB Views: 2
-
214.4 KB Views: 2
-
255.1 KB Views: 3
-
258.5 KB Views: 3
-
259.6 KB Views: 3
-
262.2 KB Views: 2
-
262.4 KB Views: 2
-
265.4 KB Views: 2
-
266.7 KB Views: 2
-
263.7 KB Views: 2