| ??? 01/25/03 14:13 Read: times |
#37253 - RE: Simple LED Test Program |
I wrote this in Keil ,but it compiles and runs okay under Raisonance.
/* * * * * * * * * * * * * * * * * * * * * * * * Name: LED Test Program * Purpose: To demonstrate the use of a timer * ISR to toggle a LED. * Assumes use of 11.059 xtal */ #include <reg51.h> #include <stdio.h> #define LED_freq 5 // in seconds // Port assignation - edit to suit you board layout. sbit LED1 = P0^0; // toggled by ISR // Memory data unsigned char tick_count; data unsigned int second_count; //***************************************************** // timer interrupt(11.059/12) /65535 =14 per second(ish) void Timer0(void) interrupt 1 using 2 { tick_count++; //if one second has passed ,incement second_count. if(tick_count>14){ tick_count=0; second_count++; if(second_count>(LED_freq-1)){ second_count=0; LED1^=LED1; }/* end of second_count>3 */ }/* end of tick_count>14 */ } /* * * * * * * * * * * * * * * * * * * * * * * * * Name: main() * Purpose: main procedure for this program */ void main(void) { TMOD = 0x01; // timer 0, mode 1, 16bit timer TR0 = 1; // Enable timer 0 ET0 = 1; // Enable Timer 0 interrupts EA = 1; // Enable interrupts while (1) {} /* end of while */ } /* end of main() routine */ |
| Topic | Author | Date |
| Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success | 01/01/70 00:00 | |
| RE: Simple LED Test Program - Success- | 01/01/70 00:00 | |
| RE: Simple LED Test Program | 01/01/70 00:00 | |
RE: Simple LED Test Program | 01/01/70 00:00 |



