Question: The sensor s output voltage can be digitized with one of the ADC channels in the MCU. The ADC has a maximum of 1 4

The sensors output voltage can be digitized with one of the ADC channels in the MCU. The ADC has a
maximum of 14 bits of resolution, providing 16,384 levels of voltage digitization. The reference voltage is
provided by the voltage reference module in the MCU. The module provides three selections of voltages: 1.2,
1.45 and 2.5 V. For example, if 2.5 V is used, the ADC provides a resolution of 0.15 mV (2.5/16384)
The example project,
C:\ti\simplelink_msp432p4_sdk_3_40_01_02\examples
ortos\MSP_EXP432P401R\driverlib\adc14_single
_conversion_repeat_timera_source\ccs, illustrates how to set up various modules to do the timer triggering.
Basically, it sets up the A0 timer to count in Up mode and Compare register 1(TA0CCR1) to generate a
pulse train to trigger an ADC sampling on the rising edge of a pulse.
Use the previous project and the example project, and adapt accordingly, to produce the same results in the
previous exercise. Note that the example project uses ADC input channel A0, but the temperature sensor
uses A22. Define the sampling frequency to use with following statement:
#define SAMPLING_FREQUENCY 100// Sampling frequency in Hz
Compute the necessary parameters in the program based on this constant and the current frequency of the
system (do not hard-code the system clock frequency or its period). For more precise timing, use SMCLK
(not ACLK) for the timer module setup. The duty cycle of the pulse train is not important here. So, use
something reasonable.
Do not enter sleep mode in the control loop in main()(as it is done in the example project). There is no
triggering action in the control loop because it is now all done by the timer. Since we are sampling at a much
higher rate than the rate to print to the console, the ISR can just update a global variable to contain the latest
digitized value, and the control loop just uses it when needed.
Before the control loop is entered, do a quick measurement on the sampling frequency to verify that the ADC
is indeed sampling at the desired rate. For example, we can measure how long it takes to collect 10 samples
with the Timer32 timer. Print the measured frequency to the debug console. If the measurement is
implemented properly, the measured frequency should be very close to the defined macro
SAMPLING_FREQUENCY because the timing is all controlled by hardware; the error should be less than
0.01 Hz. Note that there are two software tasks going on at the same time here. One is the ISR being
invoked periodically to update the global variable containing the latest digitized value, and the other is main()
doing the measurement. In order to measure the sampling rate accurately, we need to pay attention to when
the digitization cycle starts or ends.
After the quick measurement is done, enter the forever control loop to show the digitized value and voltage
at a regular interval. Note that the display frequency in the control loop (the foreground task) is much lower
than the sampling (the background task) frequency.
Do not use the MAP_Interrupt_enableSleepOnIsrExit() call in your program as it is done in the example
project so that the control loop in main() can continue to run after an interrupt is processed. Also do not use
MAP_CS_initClockSignal() as it will change SMCLK to a much lower value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!