@安小芯
感谢论坛给与测评机会,得到板块爱不释手。 感谢论坛袁大神的指导file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif
1.下面我先上原理图: 原计划使用原理图:
2.核心板与功能板飞线,理解一下,为什么要档住相关的。 3.功能:结果只用了串口,ADC,数码管,灯,按键;点亮LED,按健控制数码管显示,串口打印相关的值(ADC)和固定的字,定时器。 4.上一个才艺: a:点亮LED说明功能跑起来了。
#define LED1_GPIO_PORT GPIOA #define LED1_GPIO_CLK RCC_AHB_PERIPH_GPIOA #define LED1_GPIO_PIN GPIO_PIN_1
#define LED2_GPIO_PORT GPIOA #define LED2_GPIO_CLK RCC_AHB_PERIPH_GPIOA #define LED2_GPIO_PIN GPIO_PIN_7
#define LED1_ON {LED1_GPIO_PORT->PBSC =LED1_GPIO_PIN;} #define LED2_ON {LED2_GPIO_PORT->PBSC = LED2_GPIO_PIN;}
LED_Initialize(LED1_GPIO_PORT,LED1_GPIO_PIN | LED2_GPIO_PIN );//GPIOA
LED1_ON; LED2_ON;
b:定时器6使LED2闪烁 TIM_TimeBaseInitTypeTIM_TimeBaseStructure;// NVIC_InitTypeNVIC_InitStructure;//
RCC_Pclk1_Config(RCC_HCLK_DIV4);//APB14分频 得到Pclk1为32MHz RCC_APB1_Peripheral_Clock_Enable(RCC_APB1_PERIPH_TIM6);//使能Timer6的时钟
NVIC_InitStructure.NVIC_IRQChannel = TIM6_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority= 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority= 0; NVIC_InitStructure.NVIC_IRQChannelCmd= ENABLE; NVIC_Initializes(&NVIC_InitStructure);
TIM_Base_Struct_Initialize(&TIM_TimeBaseStructure); TIM_TimeBaseStructure.Period = period;//周期 TIM_TimeBaseStructure.Prescaler= prescaler;//预分频 TIM_TimeBaseStructure.ClkDiv = 0; TIM_TimeBaseStructure.CntMode = TIM_CNT_MODE_UP;//向上计数 TIM_Base_Initialize(TIM6,&TIM_TimeBaseStructure);
TIM_Base_Reload_Mode_Set(TIM6,TIM_PSC_RELOAD_MODE_IMMEDIATE);//立即重装载
TIM_Interrupt_Enable(TIM6,TIM_INT_UPDATE);
TIM_On(TIM6);
在中断中TIM6_IRQHandler LED2_TOGGLE;部分略过。 c:串口打印
配我就不发出来了。 if(USART_Interrupt_Status_Get(USART1, USART_INT_RXDNE) != RESET) { /*Read one byte from the receive data register */ CH= USART_Data_Receive(USART1); Usart1_Printf("%c",CH); USART_Interrupt_Status_Clear(USART1,USART_INT_RXDNE);//clearUSART_INT_RXDNE flag } d:ADC检测NTC的值
用的是PB13 PB14脚。此处又略过配置 ADC_Value =Get_ADC_Average(ADC_Channel_15_PB13,5); //ADC_IN15 pcb NTC ADC_Valuea =Get_ADC_Average(ADC_Channel_16_PB14,5);//ADC_IN16 外部NTC e:按键控制数码亮 if(KEYi== 1){ COM0_OFF; SEG0_OFF;SEG1_OFF;SEG2_OFF;SEG4_OFF;SEG6_OFF; SEG3_ON;SEG5_ON; }else if(KEYi== 2){ COM0_OFF; SEG5_OFF;SEG2_OFF;SEG6_OFF; SEG3_ON;SEG4_ON;SEG1_ON;SEG0_ON;SEG6_ON; }else if(KEYi== 3){ COM0_OFF; SEG0_OFF;SEG2_OFF; SEG4_ON;SEG3_ON;SEG1_ON;SEG5_ON;SEG6_ON; }else if(KEYi== 4){ COM0_OFF; SEG4_OFF;SEG6_OFF;SEG0_OFF; SEG2_ON;SEG3_ON;SEG1_ON;SEG5_ON; }else if(KEYi== 5){ COM0_OFF; SEG3_OFF;SEG0_OFF; SEG4_ON;SEG2_ON;SEG1_ON;SEG5_ON;SEG6_ON; }else{ SEG3_OFF;SEG0_OFF; SEG4_OFF;SEG2_OFF;SEG1_OFF;SEG5_OFF;SEG6_OFF; } if(GPIO_Input_Pin_Data_Get(KEY2_PORT,KEY2_PIN) == PIN_RESET) { SysTick_Delay_Ms(50); if(GPIO_Input_Pin_Data_Get(KEY2_PORT,KEY2_PIN) == PIN_RESET) { KEYi++; } while(GPIO_Input_Pin_Data_Get(KEY2_PORT,KEY2_PIN) == PIN_RESET); } 就只弄了这些,有些配置没有上传上来,太多了,等下长篇大论了。
|