Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to set MSP430 Driver Library timerA configurations

Status
Not open for further replies.

Alper özel

Member level 1
Joined
Feb 28, 2015
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Turkey / Scotland
Activity points
487
I am using MSP430F5529 and MSP430 Driver Library.

As you can see, I set upMode timer configuration, compare mode configuration and enabled the initial interrupts. However, timerA interrupt is not working, I set an indicator whether cod jumps into interrupt or not: ucsFault should be different than 0 if interrupt is working but obviously not. And I don't know where am I doing wrong. I appreciate any help. Regards.

Code:
#include "driverlib.h"

uint32_t fq_SMCLK = 0;

uint32_t ucsFault;

void setConf(void);
void clockConfiguration(void);

int main(void) {

    WDT_A_hold(WDT_A_BASE);
    P1DIR |= BIT0;
    P1OUT &= ~BIT0;
    clockConfiguration();
    setConf();
    fq_SMCLK = UCS_getSMCLK();

    while(1);

}

void setConf(void)
{

	Timer_A_initUpModeParam upMode =
	{

	    //uint16_t clockSource;
		TIMER_A_CLOCKSOURCE_SMCLK,
	    //uint16_t clockSourceDivider;
		TIMER_A_CLOCKSOURCE_DIVIDER_64,
	    //uint16_t timerPeriod;
		((4000000/16/64)/120),
	    //uint16_t timerInterruptEnable_TAIE;
		TIMER_A_TAIE_INTERRUPT_ENABLE,
	    //uint16_t captureCompareInterruptEnable_CCR0_CCIE;
		TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE,
	    //uint16_t timerClear;
		//TIMER_A_DO_CLEAR,
		TIMER_A_SKIP_CLEAR,
	    //bool startTimer;
		1
	};

	Timer_A_initCompareModeParam comp =
	{
	    //uint16_t compareRegister;
	    TIMER_A_CAPTURECOMPARE_REGISTER_1,
	    //uint16_t compareInterruptEnable;
	    TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,
	    //uint16_t compareOutputMode;
		TIMER_A_OUTPUTMODE_TOGGLE_RESET,
	    //uint16_t compareValue;
		((4000000/16/64)/120)*4/5
	};

	Timer_A_initUpMode(0x0340, &upMode);

	Timer_A_initCompareMode(0x0340, &comp);

	Timer_A_enableCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);

	Timer_A_enableInterrupt(0x0340);

	Timer_A_startCounter(0x0340, TIMER_A_UP_MODE);



}



void clockConfiguration(void)
{


	P5SEL |= BIT2+BIT3;                       // Port select XT2

    UCS_initClockSignal(UCS_SMCLK, UCS_XT2CLK_SELECT, UCS_CLOCK_DIVIDER_16);

    UCS_turnOnXT2(UCS_XT2_DRIVE_4MHZ_8MHZ);

    UCS_turnOnSMCLK();

	UCS_setExternalClockSource(32000, 4000000);

	UCS_enableClockRequest(UCS_SMCLK);

}

#pragma vector = TIMER0_A0_VECTOR
__interrupt void __isr_Timer_A(void)
{
	ucsFault = 1;
	switch(TA0IV)
	{
	case 0:
		Timer_A_clearTimerInterrupt(0x0340);
		Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_0);
		Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);
		P1OUT |= BIT0;
		ucsFault = 2;
		break;
	case 2:
		Timer_A_clearTimerInterrupt(0x0340);
		Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_0);
		Timer_A_clearCaptureCompareInterrupt(0x0340, TIMER_A_CAPTURECOMPARE_REGISTER_1);
		P1OUT &= ~BIT0;
		ucsFault = 3;
		break;
	}
}
 

Hello!

I'm quite late on this one, sorry...

Rather than using driverlib, you may consider working directly with available
code. The libraries are interesting but quite often counter productive: you first
set the members of some kind of structure, ant then you call the function
Timer_A_initUpMode(0x0340, &upMode); which again copies all the info stored
in upmode to setup the timer configuration values.

So you should get the code samples related to the processor you're using, open
timer source code and adapt it to your needs.

Dora.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top