麻煩站內大佬幫我看看程式,是不是哪里出錯了
#include "stm32f10x_gpio.h"
#include "stm32f10x.h"
#include "SMG.h"
#include "SysTickDelay.h"
void lcd_init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5;
GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_ResetBits(GPIOC,GPIO_Pin_4|GPIO_Pin_5);
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8;
GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_SetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_SetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
}
void Display(int n)
{
if (n<99)
{
int i;
for (i=0;i<2;i++)
{
switch(i)
{
case 0:
GPIO_ResetBits(GPIOC,GPIO_Pin_5);
break;
case 1:
GPIO_ResetBits(GPIOC,GPIO_Pin_4);
break;
}
switch(n%10)
{
case 0:
GPIO_ResetBits(GPIOB,GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
break;
case 1:
GPIO_ResetBits(GPIOB,GPIO_Pin_13|GPIO_Pin_14);
break;
case 2:
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_14|GPIO_Pin_15);
GPIO_ResetBits(GPIOC,GPIO_Pin_7|GPIO_Pin_8);
break;
case 3:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_15);
break;
case 4:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13);
break;
case 5:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_15);
break;
case 6:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
break;
case 7:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
break;
case 8:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);
break;
case 9:
GPIO_ResetBits(GPIOC,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8);
GPIO_ResetBits(GPIOB,GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_15);
break;
}
n=n/10;
delay_ms(10);
if(n==0)
break;
}
}
}
int main(void)
{
int count;
int timecheck;
lcd_init();
count=0;
timecheck=0;
while(1)
{
Display(count);
timecheck++;
delay_ms(20);
if (timecheck>100)
{
timecheck=0;
count++;
}
}
}
uj5u.com熱心網友回復:
你指abcdefg那幾個腳?三極管那有點問題,STM32是3.3V的
uj5u.com熱心網友回復:
樓主用的數碼管是共陰極還是共陽極?1樓指出的三極管的供電問題也需要修改。uj5u.com熱心網友回復:
量一量是否保持住了轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/154143.html
標籤:單片機/工控
上一篇:NorthStar Graphical Programming 下載檢測不到com口
下一篇:晶閘管門極伏安特性
