<< Chapter < Page Chapter >> Page >

When the SD16_A ends the conversion, an interrupt is requested. While variable min is lower than 60, the temperature is written in flash memory. The memory pointer is increased by two (word). When min = 60, the system stops operation.

System configuration

Dco configuration

Adjust the DCO frequency to 1 MHz by software using the calibrated DCOCTL and BCSCTL1 register settings stored in information memory segment A.

if (CALBC1_1MHZ == 0xFF || CALDCO_1MHZ == 0xFF) {while(1); // If calibration constants erased // do not load, trap CPU!!} DCOCTL = CALDCO_1MHZ; // Set DCO to 1 MHz

Basic clock module+ configuration

Set MCLK and SMCLK to 1 MHz. Use the internal very low power VLOCLK source clock to ACLK/8 clock signal as low frequency oscillator (12 kHz):

BCSCTL1 = DIVA_3; // ACLK = 1.5 kHz BCSCTL3 = LFXT1S_2; // Set VLOCLK (12 kHz)

Sd16_a configuration

The SD16_A’s input channel is the integrated temperature sensor (A6) and it uses the signal V REF+ (1.2 V) as reference voltage. The SD16_A clock source is SMCLK. Configure the SD16_A to perform a single conversion and enable its interrupts. What are the values to write to the configuration registers?

SD16CTL = SD16REFON + SD16SSEL_1; // 1.2V ref, SMCLK SD16INCTL0 = SD16INCH_6; // Temp. sensor: A6+/-SD16CCTL0 = SD16SNGL + SD16IE; // Single conv, int. enable //********************************************************* // SD16_A Interrupt Service Routine//********************************************************* #pragma vector=SD16_VECTOR__interrupt void SD16ISR(void) {unsigned int temperature; if (min<= 60) {temperature = (SD16MEM0-0x8000)/84 - 232; write_int_flash(memo_ptr,temperature);memo_ptr += 2; }else {_NOP(); }}

Timer_a configuration

Configure Timer_A register to enable an interrupt once every second. Use the ACLK clock signal as the clock source. This timer is configured in up mode in order to count until the TAR value reaches the TACCR0 value.

TACCTL0 = CCIE; // CCR0 interrupt enabled~ TACCR0 = 1500; // this count corresponds to 1 secTACTL = TASSEL_1 | MC_1 | ID_0; // ACLK, up mode to CCR0 //********************************************************* // Timer_A Interrupt Service Routine//********************************************************* #pragma vector=TIMERA0_VECTOR__interrupt void TimerA0_ISR (void) {counter++; P1OUT ^= 0x01; // LED toogle if (counter == 60) {min++; counter = 0;SD16CCTL0 |= SD16SC; // Start SD16 conversion }}

Analysis of operation

Measure the temperature variation over 1 hour

After compiling the project and starting the debug session, before running the application, put a breakpoint at line of code with the _NOP() instruction. Go to breakpoint properties and set action to Write data to file. Name the file as Temp.dat and define the data format as integer. The data starts at address 0x01040 with a length of 3C . Run the application and let the temperature data logger acquire the values over 1 hour. Use a heater or a fan to force temperature variations during the measurement period. When execution reaches the breakpoint, the file will be available in your file system. Construct a graph using Excel or a similar tool, to plot the temperature variation obtained by the data logger.

This example and many others are available on the MSP430 Teaching ROM.

Request this ROM, and our other Teaching Materials here (External Link)

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials. OpenStax CNX. May 19, 2009 Download for free at http://cnx.org/content/col10706/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials' conversation and receive update notifications?

Ask