<< Chapter < Page Chapter >> Page >

Timer_A ISR begins by activating LED2, indicating the beginning of execution of the routine and then switches LED1 state. The counters are updated in cascade and their contents are used to update the LCD, through the routines LCD_msec() , LCD_sec() and LCD_min() . The routine ends by switching the state of the clock separation points. Finally, LED2 is turned off.

System configuration

Watchdog timer

The Watchdog Timer is disabled with the objective of reducing energy consumption, but giving up the protection afforded by it. This peripheral is configured by the WDTCTL register. Its access is protected by a password. The value to disable it:

WDTCTL = WDTPW | WDTHOLD; // Stop WDT

Fll+ configuration

A 32.768 kHz crystal is applied to the oscillator LFXT1. Since it is possible to select the internal capacitors using software, what is the value to write to the FLL_CTL0 configuration register to select the 8 pF capacitors?

FLL_CTL0 |= XCAP18PF; // Set load cap for 32k xtal

Led ports configuration

LED1 and LED2 are connected to ports P2.2 and P2.1 respectively. How should they be configured so that just the bits related to these ports have digital output functions?

P2DIR |= 0x06; // P2.2 and P2.1 as output

How should the P2OUT register be configured so that the application starts with LED1 on and LED2 off?

P2OUT |= 0x04; // LED1 on and LED2 off

Timer_a configuration

The Timer_A is configured to count until it reaches the value written in the TACCR0 unit. An interrupt is generated when it reaches that value. Which is the interrupt vector to use? ____________

Timer_A clock signal is the ACLK without division. What is the value to write in the configuration register?

TACTL = TASSEL_1 | MC_1 | ID_0; // ACLK, up mode

The TACCR0 capture/compare unit determines the Timer_A counting range. For a 100 msec response, what is the value to write in the register?

TACCR0 = 3268; // this count corresponds to 100 msec

The interrupt is configured in TACCR0 capture/compare unit. What is the value to write to the following register?

TACCTL0 = CCIE; // TACCR0 interrupt enabled //*********************************************************// Timer A ISR //*********************************************************#pragma vector=TIMERA0_VECTOR __interrupt void TimerA0_ISR (void){ P2OUT |=0x02; // LED1 turn onP2OUT ^=0x04; // LED2 tooglemsec++; LCD_msec();if (msec == 10){ msec = 0;sec++; LCD_sec();if (sec == 60) {sec = 0; min++;LCD_min(); if (min == 60){ min = 0;} }}if (sec&0x01) // toogle clock dots {P3_DOT_ON; P5_DOT_ON;} else{ P3_DOT_OFF;P5_DOT_OFF; }P2OUT&=~ 02; // LED1 turn off }

Low power mode

BIS_SR(LPM3_bits + GIE); // LPM3 with interrupts enable

Analysis of operation

Isr execution time

Performing similar procedures to those described in laboratory Timers: Lab1 - Memory clock with Basic Timer1 measure the ISR execution time. What is the value measured?

LCD refresh: ______

The LCD write routines were changed. Taking advantage of storing the data in the BCD format, the division operation can be ignored, resulting in the reduction of execution time of the Basic Timer1 ISR. Is the processing time required to refresh the LCD constant? _____

Measurement of electrical current drawn

The power consumption was discussed in the previous point. The electrical power required by the system during operation is measured by replacing the jumper on the Header PWR1 by an ammeter, which indicates the electric current taken by device during operation.

What is the value read? __________

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