本帖最后由 将爱 于 2019-12-20 10:33 编辑
板子到手已经有几天了,看已经有好多坛友发表了评测,我也抓紧时间做了个音乐频谱,相比起单调的评测这样会更好玩点。
首先爆照环节还是要有的
附带个优酷视频:视频链接 https://v.youku.com/v_show/id_XNDQ3NTc5MTQ0MA==.html?spm=a2h3j.8428770.3416059.1
频谱可通过板载按键循环切换,根据采样点是256,主频只有48M ,因此跑起来有点迟迟,而且上传视频的时候程序还有点小问题,
不过重在熟悉内部资源,视频看个乐呵就好。
定时器基本参数的初始化,AD16C4T0属于高级定时器,功能比较多,我还没搞懂void Timer_Init()
{
/* Initialize AD16C4T0 */
h_tim.perh = AD16C4T0;
h_tim.init.prescaler = 0; //48M
h_tim.init.mode = TIMER_CNT_MODE_UP;
h_tim.init.period = 4800; //48M/4800=10KÖжÏƵÂÊ
h_tim.init.clk_div = TIMER_CLOCK_DIV1;
h_tim.init.re_cnt = 0;
h_tim.period_elapse_cbk = ald_timer_period_elapsed_callback;
ald_timer_base_init(&h_tim);
/* Initialize clock source */
tim_clock.source = TIMER_SRC_INTER;
ald_timer_config_clock_source(&h_tim, &tim_clock);
/* Enable tim0 interrupt */
ald_mcu_irq_config(AD16C4T0_BRK_UP_TRIG_COM_IRQn, 1, ENABLE);
/* Enable UPDATE interrupt */
ald_timer_interrupt_config(&h_tim, TIMER_IT_UPDATE, ENABLE);
/* Start input pwm from tim0 channel 1 */
ald_timer_base_start(&h_tim);
}
void ald_timer_period_elapsed_callback(struct timer_handle_s *arg)
{
ADC_STAR_FLAG = 1;
ald_gpio_toggle_pin(GPIOC,GPIO_PIN_9);
}
ADC的初始化,本来想用DMA传输的,但是接口函数调用不对就暂时回归本质死等吧
void ADC_Init(void)
{
gpio_init_t x;
/* clear adc_handle_t structure */
memset(&h_adc, 0x0, sizeof(adc_handle_t));
/* clear adc_nch_conf_t structure */
memset(&nm_config, 0x0, sizeof(adc_nch_conf_t));
/* Initialize ADC pin */
x.mode = GPIO_MODE_INPUT;
x.odos = GPIO_PUSH_PULL;
x.pupd = GPIO_PUSH_UP;
x.odrv = GPIO_OUT_DRIVE_NORMAL;
x.flt = GPIO_FILTER_DISABLE;
x.type = GPIO_TYPE_TTL;
x.func = GPIO_FUNC_0;
ald_gpio_init(GPIOC, GPIO_PIN_2, &x);
/* Initialize adc */
h_adc.perh = ADC0;
h_adc.init.data_align = ADC_DATAALIGN_RIGHT; //ADCÓÒ¶ÔÆë
h_adc.init.scan_mode = DISABLE; //ɨÃèģʽ²»ÆôÓÃ
h_adc.init.cont_mode = DISABLE; //Á¬Ðøģʽ²»ÆôÓÃ
h_adc.init.nch_len = ADC_NCH_LEN_1; //ADC³¤¶ÈÕý³£×ª»»
h_adc.init.disc_mode = ADC_ALL_DISABLE; //ADCÖжÏģʽȫ²¿½ûÓÃ
h_adc.init.disc_nbr = ADC_DISC_NBR_1; //²»Á¬Ðøת»»Í¨µÀÊýÁ¿
h_adc.init.conv_res = ADC_CONV_RES_10; //»»Ë㾫¶È
h_adc.init.clk_div = ADC_CKDIV_128; //128·ÖƵ
h_adc.init.neg_ref = ADC_NEG_REF_VSS; //ADC¸º²Î¿¼µçѹ vss
h_adc.init.pos_ref = ADC_POS_REF_VDD; // Õý²Î¿¼µçѹ vdd
ald_adc_init(&h_adc);
/* Initialize normal convert channel */ //³õʼ»¯ÆÕͨת»»Í¨µÀ
nm_config.channel = ADC_CHANNEL_2;
nm_config.rank = ADC_NCH_RANK_1; //Õý³£Í¨µÀµÈ¼¶1
nm_config.samp_time = ADC_SAMPLETIME_4; //²ÉÑùʱ¼äλ4¸öʱÖÓÖÜÆÚ
ald_adc_normal_channel_config(&h_adc, &nm_config);
}
void Get_ADC()
{
// while( ald_adc_start_by_dma(&h_adc, ADC_Value, 1, ADC_CHANNEL_14) != OK );
// ald_adc_start_by_dma(&h_adc, &ADC_Value, 1, ADC_CHANNEL_14);
ald_adc_normal_start(&h_adc);
if (ald_adc_normal_poll_for_conversion(&h_adc, 5000) == OK)
ADC_Value = ald_adc_normal_get_value(&h_adc);
}
按键和LED初始化比较简单,这里按键用的是外部中断
void KEY_Init()
{
gpio_init_t x;
exti_init_t exti;
/* Initialize GPIO_PIN_0 as input */
x.mode = GPIO_MODE_INPUT; //Ë«Ïò
x.odos = GPIO_PUSH_PULL; //ÍÆÍì
x.pupd = GPIO_PUSH_UP; //ÉÏÀ
x.odrv = GPIO_OUT_DRIVE_NORMAL; //----
x.flt = GPIO_FILTER_DISABLE; //----
x.type = GPIO_TYPE_CMOS; //----
x.func = GPIO_FUNC_1; //----
ald_gpio_init(GPIOF, GPIO_PIN_0|GPIO_PIN_1, &x);
/* Initialize external interrupt */
exti.filter = ENABLE;
exti.cks = EXTI_FILTER_CLOCK_10K;
exti.filter_time = 10;
ald_gpio_exti_init(GPIOF, GPIO_PIN_0, &exti);
ald_gpio_exti_init(GPIOF, GPIO_PIN_1, &exti);
/* Clear interrupt flag */
ald_gpio_exti_clear_flag_status(GPIO_PIN_0);
ald_gpio_exti_clear_flag_status(GPIO_PIN_1);
/* Configure interrupt */
ald_gpio_exti_interrupt_config(GPIO_PIN_0, EXTI_TRIGGER_TRAILING_EDGE, ENABLE);
ald_gpio_exti_interrupt_config(GPIO_PIN_1, EXTI_TRIGGER_TRAILING_EDGE, ENABLE);
/* Enable external interrupt */
ald_mcu_irq_config(EXTI0_3_IRQn, 3, ENABLE);
}
void gpio_irq_handler(void)
{
/* Check and clear interrupt flag */
if (ald_gpio_exti_get_flag_status(GPIO_PIN_0)) {
ald_gpio_exti_clear_flag_status(GPIO_PIN_0);
clear_ram();
menu++;
if(menu>=3)
menu = 3;
// ald_gpio_toggle_pin(GPIOC,GPIO_PIN_8);
}
if (ald_gpio_exti_get_flag_status(GPIO_PIN_1)) {
ald_gpio_exti_clear_flag_status(GPIO_PIN_1);
clear_ram();
menu--;
if(menu<=1)
menu = 1;
// ald_gpio_toggle_pin(GPIOC,GPIO_PIN_8);
}
OLED植入也比较简单,配置好IO口即可
关于FFT,网上资料也很多,这里不再重复述,后续等我优化一下代码可以上传附件供各位参考。
选择:通过本次评估,基本熟悉了ES32F0654内部各种外部设的使用,上手还是比较快的,
另外手头还有一些朋友给的东软的8位机,借着这次送的仿真器也可以用用了
|