标题: stm32驱动数码管动态显示为何不亮?附单片机仿真程序 [打印本页]

作者: 百二秦关终属我    时间: 2024-3-16 09:47
标题: stm32驱动数码管动态显示为何不亮?附单片机仿真程序
主程序
#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, 下载次数: 59)

1.png

仿真程序.7z

225.23 KB, 下载次数: 5

程序何proteus仿真


作者: xuyaqi    时间: 2024-3-17 06:12
你没有将单片机与程序关联起来。

作者: 百二秦关终属我    时间: 2024-3-17 11:58
xuyaqi 发表于 2024-3-17 06:12
你没有将单片机与程序关联起来。

您好,又试了一遍,已经亮了。但还是有点问题。我想问一下,这个数码管动态显示,单片机晶振如果是72Mhz的话,根据这个延时函数,Delay_ms()这个参数应该是多长时间呢?




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1