I am using the example timer_a_ex2_continousModeOperationWithCCR0Interrupt to try and generate a PWM signal at P1.0.
Whenever I run the program, P1.0 goes high after some time, but never creates a PWM signal.
I have tried to modify the code some to get the PWM signal, but have had no luck so far.
Here is the code:
/* --COPYRIGHT--,BSD * Copyright (c) 2017, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --/COPYRIGHT--*/ //****************************************************************************** //! TIMER_A, Toggle LED1, CCR0 Cont. Mode ISR, DCO SMCLK //! //! Toggle LED1 using software and TA_0 ISR. Toggles every //! 50000 SMCLK cycles. SMCLK provides clock source for TACLK. //! During the TA_0 ISR, LED1 is toggled and 50000 clock cycles are added to //! CCR0. TA_0 ISR is triggered every 50000 cycles. CPU is normally off and //! used only during TA_ISR. //! ACLK = n/a, MCLK = SMCLK = TACLK = default DCO ~1.048MHz //! //! MSP430FR2xx_4xx Board //! --------------- //! /|\| | //! | | | //! --|RST | //! | | //! | |-->LED1 //! //! This example uses the following peripherals and I/O signals. You must //! review these and change as needed for your own board: //! - TimerA peripheral //! - GPIO peripheral //! //! This example uses the following interrupt handlers. To use this example //! in your own application you must add these interrupt handlers to your //! vector table. //! - Timer A0 //! //***************************************************************************** #include "driverlib.h" #include "Board.h" #define COMPARE_VALUE 50000 void main (void) { //Stop Watchdog Timer WDT_A_hold(WDT_A_BASE); //Set LED1 as an output pin. GPIO_setAsOutputPin( GPIO_PORT_P1, GPIO_PIN0 ); /* * Disable the GPIO power-on default high-impedance mode to activate * previously configured port settings */ PMM_unlockLPM5(); //Start timer in continuous mode sourced by SMCLK Timer_A_initContinuousModeParam initContParam = {0}; initContParam.clockSource = TIMER_A_CLOCKSOURCE_SMCLK; initContParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1; initContParam.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE; initContParam.timerClear = TIMER_A_DO_CLEAR; initContParam.startTimer = false; Timer_A_initContinuousMode(TIMER_A1_BASE, &initContParam); //Initiaze compare mode Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0 ); Timer_A_initCompareModeParam initCompParam = {0}; initCompParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_0; initCompParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE; initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_OUTBITVALUE; initCompParam.compareValue = COMPARE_VALUE; Timer_A_initCompareMode(TIMER_A1_BASE, &initCompParam); Timer_A_startCounter( TIMER_A1_BASE, TIMER_A_CONTINUOUS_MODE ); //Enter LPM0, enable interrupts //__bis_SR_register(LPM0_bits + GIE); //For debugger //__no_operation(); } //****************************************************************************** // //This is the TIMER1_A0 interrupt vector service routine. // //****************************************************************************** #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=TIMER1_A0_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(TIMER1_A0_VECTOR))) #endif void TIMER1_A0_ISR (void) { uint16_t compVal = Timer_A_getCaptureCompareCount(TIMER_A1_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0) + COMPARE_VALUE; //Toggle LED1 GPIO_toggleOutputOnPin( GPIO_PORT_P1, GPIO_PIN0 ); //Add Offset to CCR0 //Timer_A_setCompareValue(TIMER_A1_BASE, // TIMER_A_CAPTURECOMPARE_REGISTER_0, // compVal // ); // Reset timer //Timer_A_clear(TIMER_A1_BASE); //Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0); Timer_A_clearTimerInterrupt(TIMER_A1_BASE); }