- Forums
- Resources
- About
- Groups
Close
开发板上有一个10K的电位器连接到P2.4引脚可以用作ADC的测试,前一贴使用SPI驱动了屏幕刚好我们可以把AD转换的电压值显示到屏幕上。
对于TLE9869来说,ADC模块最高可以达到10位的转换精度,具体的特性如下所示:
25 10-Bit Analog Digital Converter (ADC1)
25.1 Features
The principal features of the ADC1 are:
? Up to 8 analog input channels (channel 7 reserved for future use)
? Flexible results handling
- 8-bit and 10-bit resolution
? Flexible source selection due to sequencer
- insert one exceptional sequence (ESM)
- insert one interrupt measurement into the current sequence (EIM), single or up to 128 times
- software mode
? Conversion sample time (separate for each channel) adjustable to adapt to sensors and reference
? Standard external reference (VAREF) to support ratiometric measurements and different signal scales
? DMA support, transfer ADC conversion results via DMA into RAM
? Support of suspend and power saving modes
? Result data protection for slow CPU access (wait-for-read mode)
? Programmable clock divider
? Integrated sample and hold circuitry
转换模式有多种可选,这里我们选择正常序列模式。
使用IFXConfigWizard来生成初始化头文件,八个序列都选择上通道4即可。
main.c文件:
uint16 mV;
bool value_valid;
char str[16] = {0};
int main(void)
{
/*****************************************************************************
** initialization of the hardware modules based on the configuration done **
** by using the IFXConfigWizard **
*****************************************************************************/
SCU_Init();
INT_Init();
Port_Init();
SSC1_Init();
OLED_Init();
OLED_Fill();
OLED_Clear();
Adc1_Init();
VAREF_Enable();
/*****************************************************************************
** place your application code here **
*****************************************************************************/
/*****************************************************************************
** main endless loop **
*****************************************************************************/
/*lint -e716 info while(1) ... */
/*lint -e9036 Supressing MISRA 2012 Rule 14.4 */
while (1)
/*lint -e9036 */
/*lint -e716 */
{
/***************************************************************************
** main watchdog1 (WDT1) service **
***************************************************************************/
/*lint -e534 Supressing MISRA 2012 MISRA 2012 Directive 4.7 */
WDT1_Service();
/*lint +e534 */
/***************************************************************************
** place your application code here **
***************************************************************************/
OLED_ShowString(0,0,"Infineon",16);
OLED_ShowString(0,2,"**TLE9869 Poti**",16);
OLED_ShowString(0,4,"******demo******",16);
value_valid = Adc1_GetChResult_mV(&mV, ADC1_CH4);
if (value_valid == true)
{
sprintf(str,"V = %1.3f",mV*0.001);
OLED_ShowString(0,6,str,16);
}
}
}
上个图看看效果,很直观。
只有注册用户才能在此添加评论。 如果您已经注册,请登录。 如果您还没有注册,请注册并登录。