Lesson 7: Part 1: ADC - Reading On Chip Temperature Sensor

MCU is consider the processing unit of the embedded system. In order to allow MCU 'process', certain data need to be collect and feed into the system. For example, for a temperature monitoring system, it may require to pickup the current temperature from a temperature sensor. Or a burglar system will require to read current door contact sensor and feed into MCU. Base on these input then MCU will act accordingly.

There are may method the data (or sensor data) can be receive by MCU such as: SPI bus, IIC bus, ADC. We will be touching on SPI/IIC in future, for this lesson, our focus will be on ADC, which stands for 'Analog to Digital Converter'. As the name imply, the functionality of ADC is to convert analog signal(in this case is voltage) to binary data.

Take temperature sensor as example, when the temperature is changing, the resistance of the sensor will varies. Using this characteristic and apply the sensor into voltage divider circuit, we will have a voltage output that change according to the temperature. By using ADC, MCU can know the current voltage level, thus enabling system to know current temperature.

After reading the ADC section in Reference Manual (RM0360), there is actually an internal temperature sensor (Vsense). This would be an good example to demonstrate ADC function in reading temperature.

p.s:
Despite the idea of demostrating tempeature reading, it appears that much more work is require in order to perform a proper temperature reading, as described in RM0360: Section 12.9. Thus, the example would only demonstrate a ADC value change (increase) correspond to temperature increase.

Controlling ADC

Key function to enabling ADC is summarizes as below:
  1. Enable ADC peripheral
  2. Configurations on ADC
  3. ADC channel selection
  4. Start ADC process
  5. Wait for ADC process complete, then read the result
The source code can get obtain from here.


No comments:

Post a Comment