数码管采用595驱动,所以使用SPI通信。
所以只需配置SPI端口就行。
以下为电路图`这是代码#include “shumaguan.h”
/—————–ÊýÂë¹ÜÏÔʾµÄÊý¾Ý£¨0~9£©µÄ¶ÎÂë——————-/
u8 const Display_TAB[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
extern void Delay_Ms(u16 time);
/*
**ÅäÖÃÊýÂë¹ÜSPI¶Ë¿Ú
**PA.3 595Ëø´æ¶Ë
**PA.5 SPI1_SCK
**PA.6 SPI1_MISO ÓÉÓÚÎÒÃÇÖ»ÓøøÊýÂë¹Ü·¢Êý¾ÝËùÒԴ˶˿ÚÓò»µ½
**PA.7 SPI1_MOSI
*/
void SMG_SPI_Config(void)
{
GPIO_InitTypeDef GPIO_InitStucture;
SPI_InitTypeDef SPI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);//ʹÄÜGPIOAʱÖÓ
/*ÅäÖÃÊýÂë¹ÜËø´æ¶Ë*/
GPIO_InitStucture.GPIO_Pin = GPIO_Pin_3; //PA.3Ëø´æ¶Ë½ÓÊýÂë¹ÜST
GPIO_InitStucture.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStucture.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA,&GPIO_InitStucture); //³õʼ»¯PA.3¶Ë¿Ú
/*
**ÅäÖÃÊýÂë¹ÜSPI¶Ë¿Ú
*/
GPIO_InitStuct