【极海 APM32E103VET6S开发板】评测4、简易示波器
[复制链接]
本帖最后由 wenyangzeng 于 2022-9-24 10:47 编辑
【极海 APM32E103VET6S开发板】评测4、简易示波器
本次评测综合整个评测过程的资源,将极海 APM32E103VET6S开发板组成一台简易示波器。
使能DAC1通道1产生正弦波测试信号,连接ADC1的通道2。ADC1通道2采正弦波信号数据,在屏幕显示正弦波波形,并计算出峰-峰值,在屏幕下方显示正弦波峰-峰电压值。
ADC1配置
DAC1配置
主要代码
#include "main.h"
#include "adc.h"
#include "dac.h"
#include "gpio.h"
uint16_t sinewave[60] = {
0x07ff,0x08cb,0x0994,0x0a5a,0x0b18,0x0bce,0x0c79,0x0d18,0x0da8,0x0e29,0x0e98,0x0ef4,0x0f3e,0x0f72,0x0f92,0x0f9d,
0x0f92,0x0f72,0x0f3e,0x0ef4,0x0e98,0x0e29,0x0da8,0x0d18,0x0c79,0x0bce,0x0b18,0x0a5a,0x0994,0x08cb,0x07ff,0x0733,
0x066a,0x05a4,0x04e6,0x0430,0x0385,0x02e6,0x0256,0x01d5,0x0166,0x010a,0x00c0,0x008c,0x006c,0x0061,0x006c,0x008c,
0x00c0,0x010a,0x0166,0x01d5,0x0256,0x02e6,0x0385,0x0430,0x04e6,0x05a4,0x066a,0x0733};
void SystemClock_Config(void);
uint32_t aADCxConvertedValues;
uint8_t ADC_END=0;
void Disp(uint16_t data)
{uint8_t buffer[4];
uint8_t i;
buffer[0]=data%10000/1000;
buffer[1]=data%1000/100;
buffer[2]=data%100/10;
buffer[3]=data%10;
for(i=0;i<4;i++)
{
lcd_draw_font_num32(100+(i*24),200,RED,BLUE,buffer);
}
}
int main(void)
{
float Voltage;
uint16_t i,j,max,min;
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ADC1_Init();
MX_DAC_Init();
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
HAL_ADC_Start_IT(&hadc1);
lcd_init();
GPIOB->ODR &=~0X0100;
lcd_clear(BLUE);
lcd_draw_font_gbk16(48,210,RED,BLUE,"Vp-p = mV");
while (1)
{
j=0;
max=0x00;
min=0xffff;
for(i=0;i<319;i++)
{
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R,sinewave[j++]) ;
while(ADC_END==0);
ADC_END=0;
Disp_Voltage_Point(i,20+aADCxConvertedValues>>5);
if(max<aADCxConvertedValues)
max=aADCxConvertedValues;
if(min>aADCxConvertedValues)
min=aADCxConvertedValues;
if(j==60)
{
Voltage=(float)((max-min)*0.858);
Disp((uint16_t)Voltage);
max=0x00;
min=0xffff;
j=0;
}
}
}
}
运行结果
极海 APM32E103VET6是一款性能优良的Cortex-M3芯片,它完全兼容STM32系列,是首选的ST系列替代品。感谢EEWORLD,感谢极海科技提供一次宝贵的评测机会,谢谢。
|