Skip to content Skip to navigation

Connexions

You are here: Home » Content » Laboratory Timers: Lab3 - Memory Clock with Timer_A

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • TI MSP430 display tagshide tags

    This module is included inLens: Texas Instruments MSP430
    By: Texas InstrumentsAs a part of collection: "Teaching and classroom laboratories based on the “eZ430” and "Experimenter's board" MSP430 microcontroller platforms and Code Composer Essentials"

    Comments:

    "This is an excerpt from the MSP430 Teaching CD produced under TI sponsorship and review at the University Beira Interior in Portugal. The material covers everything from "hello world" on an eZ430 […]"

    Click the "TI MSP430" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Laboratory Timers: Lab3 - Memory Clock with Timer_A

Module by: Pedro Dinis, António Espírito Santo, Bruno Ribeiro. E-mail the authors

Summary: Using the MSP-EXP430FG4618 Development Tool and the MSP430FG4618 device implement a Memory Clock with Timer_A.

Laboratory Timers: Lab3 - Memory Clock with Timer_A

Introduction

Correct system timing is a fundamental requirement for the proper operation of a real-time application. The timing definition can dictate how the data information processed during the execution of the application program. The clock implementations vary between devices in the MSP430 family. Each device provides different clock sources, controls and uses. This chapter discusses the clock controls included in the platforms used. The MSP430 4xx family has two general-purpose 16-bit or 8-bit counters and event timers, named Timer_A, Timer_B, and a Basic Timer. The Basic Timer module is only implemented in ‘4xx devices. The 2xx device family also has Timer_A and Timer_B, but the clock signals are provided by the basic clock module+. The timers may receive an internal or external clock. Timer_A and Timer_B also include multiple independent capture and compare blocks, with interrupt capabilities.

Overview

The objective of this laboratory is to build a memory clock similar to the one that was developed using the Basic Timer1, in laboratory Timers: Lab1 - Memory clock with Basic Timer1. Timer_A is configured to generate an interrupt once every 100 msec. The ISR manages the memory clock. LED1 and LED2 are used to monitor the operation of the system state.

Resources

This application ( Lab3_Timers.c ) makes use of Timer_A to generate an interrupt when the value in the TACCR0 unit is reached. The ISR updates the contents of the memory clock variables.

LED1 monitors the system operation, switching state whenever the Timer_A ISR runs. LED2 can be used to monitor the ISR execution time. The contents of the LCD is updated every interrupt. When the ISR finishes, the device returns to low power mode.

Hence, the system resources used by this application are:

- Timer_A;

- I/O ports;

- LCD;

- Interrupts;

- Low power modes.

The default configuration of the FLL+ is used, so all the clock signals required for the operation of the device assume their default values.

Software application organization

The first task is to disable the Watchdog Timer. All the resources needed for the LCD are then configured. Once configured, the LCD is cleared by the execution of the routine LCD_all_off().

The memory clock consists of three global variables: min, sec, msec, of the type unsigned char, to store the minutes, seconds and milliseconds respectively of the values elapsed since the beginning of the execution of the application. These variables are initialized with zeros.

The LCD is refreshed at startup to display the initial clock value.

LED2 is used as an indicator of Timer_A ISR execution. The execution time can be monitored using it. In addition, LED1 switches state whenever Timer_A ISR is executed.

Timer_A is configured to generate an interrupt once every 100 milliseconds.

The routine main() ends with a global interrupt enable and puts the device into a low power mode, where it waits for the next interrupt.

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 on
 P2OUT ^=0x04; // LED2 toogle
 
 msec++;
 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 https://www-a.ti.com/apps/dspuniv/teaching_rom_request.asp

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks