{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
ADC12 and DAC12 Modules by Alex Milenkovich, [email protected] Objective: This tutorial discusses the use of MSP430’s 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, [email protected] // //****************************************************************************** #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);
Image of page 1

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

View Full Document Right Arrow Icon
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')) {
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern