【AT32F421测评】+ ADC数据采集及显示
<p>在AT32F421的内部,配置有采样率高达2M SPS的12位15通道高速ADC,可充分满足高速数据采集、混合信号处理和工业控制与电机应用要求。</p><p>此外,在ADC的基础上还配置了一个内部温度采集通道,利用它可以检测片内温度的变换情况。将该功能与前面介绍的串行数码管显示模块相配合,则可以达到图示的显示效果。</p>
<p></p>
<p>片内温度显示效果图</p>
<p>实现显示效果的主程序为:</p>
<pre>
<code class="language-cpp">int main(void)
{
int w;
RCC_Configuration();
Delay_init();
DMA_Reset(DMA1_Channel1);
DMA_DefaultInitParaConfig(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADCConvertedValue;
DMA_InitStructure.DMA_Direction = DMA_DIR_PERIPHERALSRC;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PERIPHERALINC_DISABLE;
DMA_InitStructure.DMA_MemoryInc = DMA_MEMORYINC_DISABLE;
DMA_InitStructure.DMA_PeripheralDataWidth = DMA_PERIPHERALDATAWIDTH_HALFWORD;
DMA_InitStructure.DMA_MemoryDataWidth = DMA_MEMORYDATAWIDTH_HALFWORD;
DMA_InitStructure.DMA_Mode = DMA_MODE_CIRCULAR;
DMA_InitStructure.DMA_Priority = DMA_PRIORITY_HIGH;
DMA_InitStructure.DMA_MTOM = DMA_MEMTOMEM_DISABLE;
DMA_Init(DMA1_Channel1, &DMA_InitStructure); DMA_ChannelEnable(DMA1_Channel1, ENABLE);
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanMode = DISABLE;
ADC_InitStructure.ADC_ContinuousMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrig = ADC_ExternalTrig_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NumOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC1, ADC_Channel_TempSensor, 1, ADC_SampleTime_239_5);
ADC_DMACtrl(ADC1, ENABLE);
ADC_TempSensorVrefintCtrl(ENABLE);
ADC_Ctrl(ADC1, ENABLE);
ADC_RstCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
ADC_SoftwareStartConvCtrl(ADC1, ENABLE);
AT_eval_smg_init();
Init_MAX7219();
Write_Max7219(0x0f,0x00);
Write_Max7219(1,0x0f);
Write_Max7219(2,0x0f);
Write_Max7219(3,0x0f);
Write_Max7219(4,0x0f);
Write_Max7219(5,0x0f);
Write_Max7219(6,0x0f);
Write_Max7219(7,0x0f);
Write_Max7219(8,0x0f);
while (1)
{
Delay_sec(1);
w=(ADC_TEMP_BASE-(double)ADCConvertedValue*ADC_VREF/4096)/ADC_TEMP_SLOPE+25;
Write_Max7219(1,w%10);
Write_Max7219(2,w%100/10);
}
}</code></pre>
<p>其中的显示函数Write_Max7219(i,n)的用法为:i用于指定显示的位置,由左至右是1~8;而n是显示的数值0~9。当n为0x0f时,则关闭该位的显示。</p>
<p>不错,期待后续哈</p>
<p>感谢分享!期待后续测评!</p>
soso 发表于 2021-5-10 08:49
不错,期待后续哈
<p>感谢支持和鼓励!</p>
w494143467 发表于 2021-5-10 17:34
感谢分享!期待后续测评!
<p><img height="48" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/handshake.gif" width="48" /></p>
<p>楼主测评的很好</p>
<p>这颗还配置了一个内部温度采集通道,不错</p>
Jacktang 发表于 2021-5-11 07:32
楼主测评的很好
这颗还配置了一个内部温度采集通道,不错
<p>感谢支持,继续努力!</p>
页:
[1]