void DisPlayNum(int n) //nΪÈýλÊý
{
if (n < 1000)
{
int k;
for (k=0;k<3;k++)
{
GPIO_SetBits(GPIOF,GPIO_Pin_13|GPIO_Pin_12|GPIO_Pin_11);//关闭所有数码管位选
GPIO_SetBits(GPIOE,GPIO_Pin_15|GPIO_Pin_14|GPIO_Pin_13|GPIO_Pin_12|GPIO_Pin_11|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7);//关闭所有段选
switch (k) //0-2循环,选中位选
{
case 0:
GPIO_ResetBits(GPIOF,GPIO_Pin_13);
break;
case 1:
GPIO_ResetBits(GPIOF,GPIO_Pin_12);
break;
case 2:
GPIO_ResetBits(GPIOF,GPIO_Pin_11);
break;
}
switch (n % 10) //对应位选 依次取个十百位
{
case 0:
GPIO_Write(GPIOE,table[0]);
break;
case 1:
GPIO_Write(GPIOE,table[1]);
break;
case 2:
GPIO_Write(GPIOE,table[2]);
break;
case 3:
GPIO_Write(GPIOE,table[3]);
break;
case 4:
GPIO_Write(GPIOE,table[4]);
break;
case 5:
GPIO_Write(GPIOE,table[5]);
break;
case 6:
GPIO_Write(GPIOE,table[6]);
break;
case 7:
GPIO_Write(GPIOE,table[7]);
break;
case 8:
GPIO_Write(GPIOE,table[8]);
break;
case 9:
GPIO_Write(GPIOE,table[9]);
break;
}
n = n / 10;
if (n==0)
break;
}