描述
1、stm32控制4位共阳数码管输出计数
用stm32控制4位数码管,需要用到GPIO口 PA0~PA11共12个引脚。首先我们来看看数码管的原理图。
因为是共阳所以12,9,8,6为电源输入,其他引脚均为接地,所以对于芯片来说12,9,8,6高位输出,其他设定为低位即可。
//设定下GPIO口
void GPIO_Num_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Sp