|
主程序
#include "stm32f10x.h" // Device header
#include "Delay.h"
uint16_t temp, i, j;
uint8_t table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //定義0~9的共陰極
uint16_t wei[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xff,0xff}; //位碼
uint16_t disp[2];
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE); //使能GPIOB和GPIOC時鐘
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //配置PB口為推挽輸出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //GPIOB速度為50MHz
GPIO_Init(GPIOB,&GPIO_InitStructure); //初始化PB口
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //配置PC口為推挽輸出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //GPIOC速度為50MHz
GPIO_Init(GPIOC,&GPIO_InitStructure); //初始化PC口
while(1)
{
for(i=1;i<7;i++)
{
GPIO_Write(GPIOB,wei[i-1]);
GPIO_Write(GPIOC,table[ i]);
Delay_ms(2);
GPIO_Write(GPIOB,0xff);
Delay_ms(2);
}
}
}
希望有人看到能夠幫一下,實在搞不懂啦。
|
-
1.png
(86.84 KB, 下載次數(shù): 59)
下載附件
2024-3-16 17:58 上傳
-
-
仿真程序.7z
2024-3-16 17:58 上傳
點擊文件名下載附件
225.23 KB, 下載次數(shù): 5
程序何proteus仿真
|