新手上路
- 积分
- 35
- 金钱
- 35
- 注册时间
- 2015-10-16
- 在线时间
- 1 小时
|

楼主 |
发表于 2015-10-17 10:42:29
|
显示全部楼层
回复【4楼】正点原子:
---------------------------------
这个是根据51改过来的。当时是一晃而过。显示1111.
我是直接拿并行数码管接的。 a口段 b4567 位抄作
#include "sys.h"
#define wei0  Bout(5)
#define wei1  Bout(6)
#define wei2  Bout(7)
#define wei3  Bout(8)
u32 qian,bai,ge,shi;
u32 table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82, 0xf8,0x80,0x90} ;
void delay(u32 time)
{
u32 i=0;
while(time--)
{
i=12000;
while(i--);
}
}
void LED_Ini(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE); //????PA,PD?????±??
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; //LED0--> A.8 ????????
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO????????50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void display(u32 a)
{
qian=a/1000;
bai=(a%1000)/100;
shi=(a%1000)%100/10;
ge=(a%1000)%100%10;
GPIO_Write(GPIOA,table[ge]);
wei0 = 0;
delay(10);
wei0 = 1;
GPIO_Write(GPIOA,table[shi]);
wei1 = 0;
delay(10);
wei1 = 1;
GPIO_Write(GPIOA,table[bai]);
wei2 = 0;
delay(10);
wei2 = 1;
GPIO_Write(GPIOA,table[qian]);
wei3 = 0;
delay(10);
wei3 = 1;
}
int main(void)
{
LED_Ini();
display(1234);
delay(5000);
} |
|