<< Chapter < Page Chapter >> Page >
Using the MSP-EXP430FG4618 Development Tool and the MSP430FG4618 device perform a frequency measurement.

Laboratory timers: lab5 - frequency measurement

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

This laboratory implements an application ( Lab5_Timers.c ) designed to measure a PWM signal frequency. If a signal generator is not available, the microcontroller generates a PWM signal based on the frequencies stored in a file. The frequencies generated are read and updated with a fixed time period using the features of CCE . The measured value is shown on the LCD in Hz.

Resources

The module FLL+ is configured to a frequency of 7.995392 MHz for the MCLK and SMCLK clock signals. This application performs the two tasks simultaneously.

On the one hand, it generates a PWM signal with a frequency of 200 Hz and a duty cycle of 50%. Alternatively, the PWM signal frequency can be read from a file using a breakpoint. This function is performed by Timer_B, using the compare unit to generate the PWM signal.

The time period between two consecutive PWM signals low-to-high transitions is measured by Timer_A. The capture unit of this timer is configured to collect the Timer_A counter register’s contents when a PWM signal low-to-high transition is detected at its input.

The Basic Timer1 generates an interrupt once every second. The ISR updates the PWM signal frequency generated by the Timer_B. If you choose to use this feature, a breakpoint associated with this ISR execution allows reading a file with the value of the frequency that will be generated.

The microcontroller’s ports are configured in order that the PWM signal generated by Timer_B through the TBCCR4 compare unit available at Port P3.5/TB4 can be connected to the Port P1.2/TA1 of the Timer_A TACCR1 capture unit. If you plan to use this feature, these pins must be connected together. Port P3.5 pin is available on Header 7 pin 6, while the Port P1.2 pin is available on Header H2 pin 3.

Ports P2.1 and P2.2 are used to monitor the state of the LED2 and LED1, respectively.

The resources used by the application are:

- Timer_A;

- Timer_B;

- Basic Timer1;

- I/O ports;

- FLL+;

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