1 / 23

LAB 5: ADC

CS 4101 Introduction to Embedded Systems. LAB 5: ADC. Chung-Ta King National Tsing Hua University. Introduction. In this lab, we will learn The configuration of ADC10 The use of ADC10 to detect the internal temperature of LauchPad. ADC of MSP430 .

etana
Download Presentation

LAB 5: ADC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 4101 Introduction to Embedded Systems LAB 5: ADC Chung-Ta King National TsingHua University

  2. Introduction • In this lab, we will learn • The configuration of ADC10 • The use of ADC10 to detect the internal temperature of LauchPad

  3. ADC of MSP430 • Provide continuous sampling of multiple analog inputs and store sampled data

  4. ADC of MSP430 • Provide continuous sampling of multiple analog inputs and store sampled data Interrupt CPU on every word sampled from ADC Use software (ISR run bythe CPU) to move datafrom ADC to memory

  5. ADC of MSP430 • Provide continuous sampling of multiple analog inputs and store sampled data Use hardware (DataTransfer Controller, DTC)to move data from ADC to memory Interrupt CPU whenblock transfer is completed

  6. Voltage reference Clock sources Conversion trigger Simplified Block Diagram of ADC10

  7. Enabling Sampling and Conversion

  8. Steps for Single Conversion (1) Configure ADC10, including the ADC10ON bit to enable the module. • The ENC bit must be clear so that most bits in ADC10CTL0 and ADC10CTL1 can be changed. (2) Set the ENC bit to enable a conversion. • This cannot be done while the module is being configured in the previous step. (3) Trigger the conversion, either by setting the ADC10SC bit or by an edge from Timer_A. • ADC10ON, ENC, ADC10SC are all in control register ADC10CTL0

  9. ADC10 Registers Where the data is saved

  10. ADC10CTL0 ideal for the temperature sensor ideal for the temperature sensor

  11. ADC10CTL0 cont’d

  12. ADC10CTL1

  13. ADC10CTL1 cont’d

  14. Sample Code 1 for ADC10 • Repetitive single conversion: • A single sample is made on A1 with reference to Vcc • If A1 > 0.5*Vcc, P1.0 set, else reset. • Software sets ADC10SC to start sample and conversion. ADC10SC automatically cleared at end of conversion. • Use ADC10 internal oscillator to time the sample and conversion.

  15. Sample Code 1 for ADC10 15

  16. Sample Code 1 for ADC10 16

  17. Sample Code 2 for ADC10 • Continuous sampling driven by Timer_A • A1 is sampled 16/second (ACLK/2048) with reference to 1.5V, where ACLK runs at 32 KHz driven by an external crystal. • If A1 > 0.5Vcc, P1.0 is set, else reset. • Timer_A is run in up mode and its CCR1 is used to automatically trigger ADC10 conversion, while CCR0 defines the sampling period • Use internal oscillator times sample (16x) and conversion (13x).

  18. Sample Code 2 for ADC10 18

  19. Sample Code 2 for ADC10 Timer_A CCR1 out mode 3: The output (OUT1) is set when the timer counts to the TACCR1 value. It is reset when the timer counts to the TACCR0 value. 19

  20. Sample Code 2 for ADC10 20

  21. Basic Lab • Measure the temperature of MSP430 every second using the temperature sensor inside ADC10. Flash the red LED if the temperature rises and the green LED if it drops. Flash both LEDs if the temperature remains unchanged between two consecutive measurements. • The sampling of ADC10 must be triggered continuously by Timer_A. • You can use an infinite loop to flash the LEDs.

  22. Close watchdog timer • Set DCO as src of MCLK, 1 MHz, and VLO as ACLK • Setup both LED lights and set it initially off • You can modify the sample code 2 to finish the basic, you can first set timer_A source from MCLK(DCO) to settle 30 micro second delay, and then set timer_A source from ACLK(VLO). • Set ADC configuration into: • Sample-and-hold source from timer_A • Temperature sensor channel • Use ideal reference • Conversion sequence mode : Repeat-single-channel • Enable ADC10 interrupt • Every second ADC10IFG is set when conversion results(temperature) are loaded into ADC10MEM and invoke ADC ISR.

  23. Bonus • Enable button interrupt. Every time the button is pushed, measure the temperature of MSP430. If the temperature is higher than 737, turn on the red light for a second. Otherwise, turn on the green light for a second.

More Related