您的当前位置:首页codeworrior流水灯代码

codeworrior流水灯代码

来源:锐游网
#include /* common defines and macros */

#include \"derivative.h\" /* derivative-specific definitions */

#include \"GPIO.h\"

void main(void) {

/* put your own code here */

// EnableInterrupts;

// DDRB = 0XFF ;

// PORTB = 0X00 ;

GPIO_Init() ;

for(;;) {

_FEED_COP(); /* feeds the dog */

GPIO_Led() ;

} /* loop forever */

/* please make sure that you never leave main */

}

#include \"GPIO.h\"

void GPIO_Init(void)

{

DDRB = 0xff ;

}

void Delay(void)

{

word i , j ;

for(i = 0 ; i < 200 ; i++)

for(j = 2000 ; j >0 ; j--) ;

}

void GPIO_Led(void)

{

PORTB = 0x7e; // 0111 1110 0x7e

Delay();

PORTB = 0xbd; Delay();

PORTB = 0xdb; Delay();

PORTB = 0xe7; Delay();

Delay();

PORTB = 0xff; Delay(); // 1011 1101 0xbd

// 1101 1011 0xdb

// 1110 0111 0xe7

// 1111 1111 0xff

PORTB = 0x00; // 0000 0000 0x00

Delay();

PORTB = 0xe7;

Delay();

PORTB = 0xdb;

Delay();

PORTB = 0xbd;

Delay();

PORTB = 0x7e;

Delay();

PORTB = 0x00;

Delay();

PORTB = 0xff;

Delay();

Delay();

}

#ifndef _GPIO_H_

#define _GPIO_H_

#include \"MC9S12XS128.h\"

typedef unsigned char byte ;

typedef unsigned int word ;

void GPIO_Init(void) ;

void Delay(void) ;

void GPIO_Led(void) ;

#endif

因篇幅问题不能全部显示,请点此查看更多更全内容

Top