//晟矽微单片机编程第八天
//qq:74145445
//快手:共同学习stm8
/**************************************************/
// MC32P7311
// _____@_____
// led11--p16|1 16|p17--anjian
// vdd|2 15|vss
// led10--p15|3 14|p00--led0
// led9--p14|4 13|p01--led1
// led8--p13|5 12|p02--led5
// led7--p12|6 11|p03--led4
// led6--p11|7 10|p04--led3
// ad --p10|8_________9|p05--led2
/**************************************************/
#define bit0 0b00000001
#define bit1 0b00000010
#define bit2 0b00000100
#define bit3 0b00001000
#define bit4 0b00010000
#define bit5 0b00100000
#define bit6 0b01000000
#define bit7 0b10000000
#define bit8 0b0000000100000000
#define bit9 0b0000001000000000
#define bit10 0b0000010000000000
#define bit11 0b0000100000000000
#define bit12 0b0001000000000000
#define bit13 0b0010000000000000
#define bit14 0b0100000000000000
#define bit15 0b1000000000000000
/**************************************************/
#define led0 P00D
#define led1 P01D
#define led2 P05D
#define led3 P04D
#define led4 P03D
#define led5 P02D
#define led6 P11D
#define led7 P12D
#define led8 P13D
#define led9 P14D
#define led10 P15D
#define led11 P16D
#define led_0_oe P00OE
#define led_1_oe P01OE
#define led_2_oe P05OE
#define led_3_oe P04OE
#define led_4_oe P03OE
#define led_5_oe P02OE
#define led_6_oe P11OE
#define led_7_oe P12OE
#define led_8_oe P13OE
#define led_9_oe P14OE
#define led_10_oe P15OE
#define led_11_oe P16OE
/**************************************************/
#include"MC32P7311.h"
void io_chushihua(); //io初始化
void xianshi(); //显示
void yanshi(); //延时
unsigned int xianshi_a1;
void main()
{
unsigned char a1;
unsigned int a2;
io_chushihua(); //io初始化
for(;;)
{
a2 =1;
for(a1=12;a1>0;a1--)
{
xianshi_a1 =a2;
xianshi();
yanshi();
a2 <<=1; //左移一位
}
}
}
/**************************************************/
void io_chushihua() //io初始化
{
led_0_oe =1; //输出口
led_1_oe =1;
led_2_oe =1;
led_3_oe =1;
led_4_oe =1;
led_5_oe =1;
led_6_oe =1;
led_7_oe =1;
led_8_oe =1;
led_9_oe =1;
led_10_oe =1;
led_11_oe =1;
}
/**************************************************/
void xianshi() //显示
{
if(xianshi_a1 & bit0){led0 =1;} else{led0 =0;}
if(xianshi_a1 & bit1){led1 =1;} else{led1 =0;}
if(xianshi_a1 & bit2){led2 =1;} else{led2 =0;}
if(xianshi_a1 & bit3){led3 =1;} else{led3 =0;}
if(xianshi_a1 & bit4){led4 =1;} else{led4 =0;}
if(xianshi_a1 & bit5){led5 =1;} else{led5 =0;}
if(xianshi_a1 & bit6){led6 =1;} else{led6 =0;}
if(xianshi_a1 & bit7){led7 =1;} else{led7 =0;}
if(xianshi_a1 & bit8){led8 =1;} else{led8 =0;}
if(xianshi_a1 & bit9){led9 =1;} else{led9 =0;}
if(xianshi_a1 & bit10){led10 =1;} else{led10 =0;}
if(xianshi_a1 & bit11){led11 =1;} else{led11 =0;}
}
/**************************************************/
void yanshi() //延时
{
unsigned int x;
x =1000;
while(x)
{
x--;
}
}
/**************************************************/
/**************************************************/
|