新手入门
- 积分
- 7
- 金钱
- 7
- 注册时间
- 2020-7-4
- 在线时间
- 5 小时
|
1金钱
程序是从F107移植过来的,在107上可以正常使用,可到了F401却无法正常显示,这是为何?
4λ12òõêyÂë1ü
8¶ÎêyÂë1üóëó2¼tòy½Å¶Ôó|1ØÏμ
λѡ£oPD12-PD15
A------->PC0
B------->PC1
C------->PC2
D------->PC3
E------->PC4
F------->PC5
G------->PC6
DP------>PC7
0£oABCDEF
1:BC
2:ABDEG
3:ABCDG
4:BCFG
5:ACDFG
6:ACDEFG
7:ABC
8:ABCDEFG
9:ABCDFG
GPIO_PIN_0 ((uint16_t)0x0001)
èç£o0 --> A|B|C|D|E|F = 0x64b
******************************/
#include "led.h"
int num[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//¶Ôó|ÏÔê¾0~9
int p=1000;
void DisPlayNum(int n)
{
if (n < 9999)
{
int i = 0;
for (i=0;i<4;i++)//ÖeλÏÔê¾£¬′óμíλÖá¸ßλÏÔê¾
{
GPIO_Write(GPIOC,0xFFFF);//ÏÔê¾Ã¿ò»Î»
GPIO_Write(GPIOA,0xF000);//PD12-15λѡÖÃλ
// switch (i)
// {
// case 0:
// GPIO_Write(GPIOD,0xE000);//PD12??,?????
// break;
// case 1:
// GPIO_Write(GPIOD,0xD000);//PD13??,?????
//// GPIO_Write(GPIOB,GPIO_Pin_SET);//???
// break;
// case 2:
// GPIO_Write(GPIOD,0xB000);//PD14??,?????
// break;
// case 3:
// GPIO_Write(GPIOD,0x7000);//PD15??,?????
// break;
// }
p = n % 10;
GPIO_Write(GPIOC, num[p]);//ÏÔê¾Ã¿ò»Î»μÄ0~9
n = n / 10;//òà′ÎÏÔê¾ÏÂò»Î»
if (n==0)//×îoóò»Î»ÏÔê¾í꣬½áêø£¨′óμíλÖá¸ßλÏÔê¾£©
break;
}
}
}
void LED_POSITION_Init(void)//λѡ1ü½Å3õê¼»ˉPA1-3
{
GPIO_InitTypeDef GPIO_InitStructure;
//---------------------------------------------------------------
/* ê1ÄüLED¶Ôó|GPIOμÄClockê±Öó */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD , ENABLE);
/* 3õê¼»ˉLEDμÄGPIO1ü½Å£¬ÅäÖÃÎaíÆíìêä3ö */ //éèÖö˿ú
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_12 |GPIO_Pin_13 |GPIO_Pin_14 |GPIO_Pin_15 ;
//éèÖöԶ˿úμÄÄ£ê½
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //éèÖÃÎa íÆíì(Push-Pull)êä3ö
//
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //×î′óêä3öËù¶èÎa50MHz
GPIO_Init(GPIOD, &GPIO_InitStructure); //μ÷óÃGPIO3õê¼»ˉoˉêy
}
void LED_SEGMENT_Init(void)//¶ÎÑ¡1ü½Å3õê¼»ˉPC0-7
{
GPIO_InitTypeDef GPIO_InitStructure;
//---------------------------------------------------------------
/* ê1ÄüLED¶Ôó|GPIOμÄClockê±Öó */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE);
/* 3õê¼»ˉLEDμÄGPIO1ü½Å£¬ÅäÖÃÎaíÆíìêä3ö */ //éèÖö˿ú
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |GPIO_Pin_1 |GPIO_Pin_2 |GPIO_Pin_3 |GPIO_Pin_4 |GPIO_Pin_5 |GPIO_Pin_6 |GPIO_Pin_7 ;
//éèÖöԶ˿úμÄÄ£ê½
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //éèÖÃÎa íÆíì(Push-Pull)êä3ö
//
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //×î′óêä3öËù¶èÎa50MHz
GPIO_Init(GPIOD, &GPIO_InitStructure); //μ÷óÃGPIO3õê¼»ˉoˉêy
}
|
-
|