lab8 - ADC12 and DAC12 Modules by Alex Milenkovich,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ADC12 and DAC12 Modules by Alex Milenkovich, milenkovic@computer.org Objective: This tutorial discusses the use of MSP430s ADC12 and DAC12 peripheral devices. Note: Required are all previous tutorials. 1. On-Chip Temperature Sensor Let us consider a C application shown in Figure 1 that samples the on-chip temperature sensor, converts the sampled voltage from the sensor to temperature in degrees Celsius and Fahrenheit, and sends the temperature sensor through a RS232 link to the Hyper-terminal application. Note: The source code for this program can be downloaded from the course secure directory (file temp_uart.c). Analyze the program and test it on the EasyWeb2 platform. Answer the following questions. What does the program do? How the basic block module is configured? How the ADC12 module is configured? How the USART0 module is configured? // Description: fMCLK = fACLK = 8MHz // // MSP430F149 // ----------------- // /|\| XIN|- // | | | XTAL (8Mhz) // --|RST XOUT|- // | | // | P2.1|-->LED // // @A. Milenkovic, milenkovic@computer.org // //****************************************************************************** #include "msp430x14x.h" #include "stdio.h" unsigned char thr_char; /* hold char from UART RX*/ unsigned char rx_flag; /* receiver rx status flag */ char gm1[67] = "Hello! I am an MSP430. Would you like to know my temperature? (Y|N)"; char gm2[9] = "Bye, bye!"; char gm3[15] = "Type in Y or N!"; long int temp; long int IntDegF; long int IntDegC; char NewKey[25]; // initialize basic clock module void InitOsc(void); // UART Initializaion void UART_Initialize(void); //send char function void UART0_putchar(char c); void main(void) { int i = 0; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer InitOsc(); UART_Initialize(); ADC12CTL0 = SHT0_8 + REFON + ADC12ON; ADC12CTL1 = SHP; // enable sample timer ADC12MCTL0 = 0x01A; ADC12IE = 0x001; rx_flag = 0; // rx default state "empty" _EINT(); // enable global interrupts // send greeting messages for(i = 0; i < 67; i++) { thr_char = gm1[i]; UART0_putchar(thr_char); } Wait: while(!(rx_flag&0x01)); // wait until receive the character from HyperTerminal rx_flag = 0; // clear rx_flag UART0_putchar(thr_char); UART0_putchar('\n'); // newline UART0_putchar('\r'); // carriage return // echo to HyperTerminal twice if ((thr_char != 'y') && (thr_char != 'n') && (thr_char !='Y') && (thr_char !='N')) { //UART0_putchar(thr_char); for(i = 0; i < 15; i++) { thr_char = gm3[i]; UART0_putchar(thr_char); } UART0_putchar('\n'); // newline UART0_putchar('\r'); // carriage return goto Wait; } if ((thr_char == 'y') || (thr_char == 'Y')) {...
View Full Document

This note was uploaded on 12/04/2011 for the course CPE 323 taught by Professor Milenkovic during the Spring '10 term at University of Alabama - Huntsville.

Page1 / 6

lab8 - ADC12 and DAC12 Modules by Alex Milenkovich,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online