??? 07/22/06 09:12 Read: times |
#120841 - Timer program Responding to: ???'s previous message |
/*
Author Nikhil Arora ele.nikhil@gmail Learning SDCC Timer program led blinked at p1.4 at every 250ms at p1.5 at 1sec and so on crystal used 11.0592MHz Program in main loop goes on parallelly */ #include <at89x051.h> //Global Variables unsigned char time1ms; unsigned char time250ms; unsigned char time1s; unsigned char time1m; //Function Prototypes void delaysec(void); void timer1_isr (void) interrupt 3 using 1 { time1ms++; if(time1ms==250) { time1ms=0; time250ms++; P1_4 = !P1_4; if(time250ms==4) { time250ms=0; time1s++; P1_5 = !P1_5; if(time1s==60) { time1s=0; P1_6 = !P1_6; time1m++; if(time1m==60) { time1m=0; P1_7 = !P1_7; } } } } TH1 = 0xfc; //Delay TL1 = 0x69; //Delay } void delaysec(void) { int i; unsigned char j; for(i=0;i<1500;i++) { for(j=0;j<100;j++){} } } void main(void) { TMOD = 0x11; // Set to 16 bit timers TH1 = 0xfc; // Delay TL1 = 0x69; // Delay ET1 = 1; // SET TIMER1 INTERRUPT time1ms = 0; // Reset time time250ms = 0; // time1s = 0; time1m = 0; TR1 = 1; // Run Timer 1 EA = 1; // ENABLE GLOBAL INTERRUPT while(1) // Main program blinking of LED at port3.7 { P3_7 = !P3_7; delaysec(); P3_7 = !P3_7; delaysec(); } } |
Topic | Author | Date |
i want to learn sdcc and keil plz help | 01/01/70 00:00 | |
Example ? | 01/01/70 00:00 | |
need simple code to start with | 01/01/70 00:00 | |
what is in the manual | 01/01/70 00:00 | |
nice site | 01/01/70 00:00 | |
try mine | 01/01/70 00:00 | |
why not use e-mail | 01/01/70 00:00 | |
This is all there for you to see | 01/01/70 00:00 | |
simple program to check the hardwar | 01/01/70 00:00 | |
Timer program | 01/01/70 00:00 | |
interrupt program | 01/01/70 00:00 | |
how bloody awful | 01/01/70 00:00 | |
Serial program | 01/01/70 00:00 | |
How to post code | 01/01/70 00:00 |