Lecture 25: Recap - A/D, Timer_A, and msp432_recorder_demo 10:10 A/D Main Points Conversion Formula from analog to digital Vin - Vref- D = floor{ ------------- . (2^n - 1) + 0.5 } Vref+ - Vref- Conversion Formula from digital to analog D Vout = ------- . (Vref+ - Vref-) + Vref- 2^n - 1 SPAN = Vref+ - Vref- ANALOG RESOLUTION = (Vref+ - Vref-) / (2^n - 1) DIGITAL RESOLUTION = n -> Chart R-2R Ladder DAC I/2 I/4 Vin --+----///R//-----+----///R//-----+---------------+ | | | | // // // // 2R I/2 2R I/4 2R I/8 2R I/8 // // // // | | | | + + + + / \ / \ / \ gnd b2-switch b1-switch b0-switch + + + + + + gnd | gnd | gnd | | | | +---------------+---------------+ | +-----+-----//R///---------+ | | | | \ | | | \ | +-----+ - \ | | +---------+---- Vout gnd -------+ + / | / | / A/D Conversion: - Sample and Hold - SAR Conversion Sample and Hold exp (-tacq / (R.C)) < 1 / 2^n => tacq > n . (R.C) . ln(2) SAR Try code 1000 -> decide 0000 or 1000 Try code n100 -> decide n000 or n100 Try code nn10 -> decide nn00 or nn10 Try code nnn1 -> device nnn0 or nnn1 done Repetitively apply DAC formula, and compare generated voltage to input voltage For n bit: conversion time = n * bit-conversion time Total conversion time = Acquisition time + Conversion time 10:20 MSP432 ADC14 Block Diagram and Driverlib Function Calls Conversion Clock INPUT 0 -|\ | +-------+ INPUT 1 -| \ V | MEM0 | INPUT 2 -| +---> S/H ---> SAR --->| ... | ... | / ^ ^ | MEM31 | INPUT 31 -|/ +---+----+ +-------+ | Analog Mux | Memory Buffer Trigger Configuration Procedure: 1/ Choose conversion mode (single channel, multichannel) - single channel/multi-channel - repetitive/ not-repetive ADC14_configureSingleSampleMode ADC14_configureMultiSequenceMode 2/ Choose conversion clock ADC14_initModule 3/ Choose sample timer (manual or auto-repeat) ADC14_enableSampleTimer 4/ Map channels to buffer locations ADC14_configureConversionMemory 5/ Configure GPIO ports to work as analog inputs GPIO_setAsPeripheralModuleFunctionInputPin Making a conversion: 0/ Enable Module ADC14_enableModule 1/ Enable conversion ADC14_enableConversion 2/ Trigger conversion ADC14_toggleConversionTrigger 3/ Wait until the ADC is done ADC14_isBusy 4/ Read the result ADC14_getResult Example of a continuous-conversion: https://github.com/vt-ece2534-s18/msp432-adc-examples/blob/master/msp432-microphone-lcd/microphone.c 10:30 Q&A from Slides 10:40 msp432-record-demo-2 - Describe program - Describe operation - 8 KHz ISR tied to Timer_A1 Listening: - Convert Sample Stream from Microphone - Explain Calibration in scaleSample - Records 16000 samples of 1 byte Playback - Use a 64 KHz PWM ON Timer_A0 - Set duty cycle to value of sample - Explain program using Timer_A Configuration 10:55 Timer_A Q&A from Slides -> Do monday