资料介绍
mc18例程
/* 1 */ #include
/* 2 */ #include
/* 4 */ #define NUMBER_OF_LEDS 8
/* 5 */
/* 6 */ void timer_isr (void);
/* 7 */
/* 8 */ static unsigned char s_count = 0;
/* 9 */
/* 10 */ #pragma code low_vector=0x18
/* 11 */ void low_interrupt (void)
/* 12 */ {
/* 13 */ _asm GOTO timer_isr _endasm
/* 14 */ }
/* 15 */
/* 16 */ #pragma code
/* 17 */
/* 18 */ #pragma interruptlow timer_isr save=PROD
/* 19 */ void
/* 20 */ timer_isr (void)
/* 21 */ {
/* 22 */ static unsigned char led_display = 0;
/* 23 */
/* 24 */ INTCONbits.TMR0IF = 0;
/* 25 */
/* 26 */ s_count = s_count % (NUMBER_OF_LEDS + 1);
/* 27 */
/* 28 */ led_display = (1 << s_count++) - 1;
/* 29 */
/* 30 */ PORTB = led_display;
/* 31 */ }
/* 32 */
/* 33 */ void
/* 34 */ main (void)
/* 35 */ {
/* 36 */ TRISB = 0;
/* 37 */ POR