Lesson 1 – ADC Wake and Transmit on Threshold

Motivation

Many applications use analog sensors (such as temperature and pressure sensors) to interface with the real-world. Based on the behavior of these sensors, the system will behave in a certain way. Traditionally, running the MCU (and CPU) to perform the measurements and to read the conversion data can be inefficient. This project proposes an alternative (more efficient) way. In order to conserve power, the CPU and other clocks will be disabled. The internal ADC will continue to operate and trigger an interrupt to the CPU when a unique adjustable threshold is reached. Also, interrupts can be used to transport conversion data without CPU intervention.

Note: The MSP430FR2433 has a 10-bit SAR ADC

Background

An ADC value is set via UART which when reached will wake up the CPU, illuminating an LED, and transmitting ADC data back over the UART.

The clock is sourced from the MSP430’s internal 32.768kHz clock. The UART clock is 1MHz.

Figure 1 – Wiring diagram

ADC sample are constantly read from P1.3 A3. The device enters a low-power mode (LPM). When the adjustable threshold is reached, the LED connected to P1.0 illuminates and the ADC conversion data is transmitted via UART.

The GUI

The GUI shows the waveform being sampled. The user can enter the triggering threshold via the text box or slider.

Once this threshold is passed, an interrupt is triggered which toggles the LED.

Figure 2 – The GUI

The Code

After initialization, the MCU enters a low-power mode (LPM) and waits for an Interrupt Service Routine (ISR). The first ISR is from the ADC that results from the threshold being reached. An LED toggles and Timer A begins.

Timer A begins its own ISR which continuously sends conversion data.

The third ISR, USCI_A0_ISR receives the conversion data from the GUI and stores it in FRAM

Question: What’s the high and low byte? Is it the conversion data?

The ADC in the MSP430FR2433 produces a 12-bit result that’s stored in the 16-bit register ADCMEM0. Since UART transits a byte at a time, the register contents is SPLIT into a high and low byte.

Figure 3 – Code flowchart