Skip to content Skip to navigation

Connexions

You are here: Home » Content » Laboratory Signal Acquisition: Lab4 - Voltage signal comparison with Comparator_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 Signal Acquisition: Lab4 - Voltage signal comparison with Comparator_A

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

Summary: Using the MSP-EXP430FG4618 Development Tool analyse the Comparator_A operation. A voltage is applied to one of the Comparator’s inputs, generated optionally by the DAC12 or by other external source. Whenever the external voltage value is higher than the comparison value internally generated, it is generated an interrupt that switches the LED state.

Laboratory Signal Acquisition: Lab4 - Voltage signal comparison with Comparator_A

Introduction

This laboratory gives examples of the uses of the ADC types available in the hardware development kits. A different laboratory is developed for each kit, taking into account that both the ADC10 and the SD16_A laboratories implement a temperature data logger. The ADC12 laboratory also uses operational amplifiers to perform the analogue signal conditioning.

Overview

This laboratory ( Lab4_ADC.c) analyses Comparator_A operation. A voltage is applied to one of the Comparator’s inputs, generated either by the DAC12 or by other external source. Whenever the external voltage value is higher than the comparison value internally generated, an interrupt is generated that switches the LED state.

Resources

The resources used by the application are:

- DAC12;

- Comparator_A;

- Digital IO;

- Timer_A.

Software application organization

The application starts by stopping the Watchdog Timer.

Timer_A is configured to generate an interrupt once every msec, and updates the DAC12 output in order to provide a ramp signal.

The Comparator_A’s output is configured to be accessible at pin P6.6, which is available on Header 4 pin 7. The signal applied to CA0 input is compared with 0.5 Vcc internal reference voltage. Every time that a compare match occurs, an interrupt is requested and switches the state of LED1.

System configuration

Comparator_A configuration

Configure the registers in order to receive the external signal at the CA0 input and compare it with the internal reference 0.5 Vcc. Enable the comparator with an interrupt triggered on a low-to-high transition of the comparator output.

CACTL1 = CAON | CAREF_2 | CARSEL | CAIE;  // Enable comp, ref = 0.5*Vcc

CACTL2 = P2CA0; // Pin to CA0

P2DIR |= 0x042; // P2.1 and P2.6 output direction
P2SEL |= 0x040; // P2.1 = LED1 and P2.6 = CAOUT 

CACTL1 |= CAIE; // Setup interrupt for Comparator


//*********************************************************
// Comp_A interrupt service routine -- toggles LED
//*********************************************************
#pragma vector=COMPARATORA_VECTOR
__interrupt void Comp_A_ISR (void)
{
 CACTL1 ^= CAIES; // Toggles interrupt edge
 P2OUT ^= 0x02; // Toggle P2.1
}    

ADC12 configuration

ADC12CTL0 = REF2_5V + REFON; // Internal 2.5V ref on

DAC12 configuration

DAC12_0DAT = 0x00; // DAC_0 output 0V

DAC12_0CTL = DAC12IR | DAC12AMP_5 | DAC12ENC;
// DAC_0->P6.6
// DAC reference Vref
// 12 bits resolution
// Imediate load
// DAC full scale output
// Medium speed/current
// Straight binary
// Not grouped
    

Timer_A configuration

// Compare mode
TAR = 0; // TAR reset
TACCR0 = 13600; // Delay to allow Ref to settle
TACCTL0 |= CCIE; // Compare-mode interrupt
TACTL = TACLR + MC_1 + TASSEL_2; // up mode, SMCLK

// Interrupt enable
TAR = 0; // TAR reset
TACCTL0 = CCIE; // CCR0 interrupt enabled
TACCR0 = 32; // 1 msec counting period
TACTL = TASSEL_1 | MC_1 | ID_0; // ACLK, up mode


//*********************************************************
// ISR to TACCRO from Timer A 
//*********************************************************
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA0_ISR (void)
{
 DAC12_0DAT++;
if (DAC12_0DAT == 0xFFF)
    DAC12_0DAT = 0;
    
    if (flag == 1) // if flag active exit LPM0
    { 
     flag = 0;
     LPM0_EXIT;
    } 
}
    

Analysis of operation

The experimental verification of this laboratory can be accomplished by connecting the DAC12’s output, available on Header 8 pin 7, to the Comparator_A’s input CA0, available on Header 4 pin 7.

Observe the signals wave form at the Comparator_A’s input and output using an oscilloscope. The LED1 switches state whenever the input’s voltage value is lower than the compare value.

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:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

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