TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP432跳不出定时器A中断为什么

/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
/* Statics */
const Timer_A_ContinuousModeConfig continuousModeConfig =
{
TIMER_A_CLOCKSOURCE_ACLK,
TIMER_A_CLOCKSOURCE_DIVIDER_8, 
TIMER_A_TAIE_INTERRUPT_ENABLE,
TIMER_A_DO_CLEAR // Clear Counter
};

int main(void)
{
/* Stop watchdog timer */
WDT_A_holdTimer();

/* Configuring P1.0 as output */
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

/* Starting and enabling ACLK (32kHz) */
CS_setReferenceOscillatorFrequency(CS_REFO_128KHZ);
CS_initClockSignal(CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_4);

/* Configuring Continuous Mode */
Timer_A_configureContinuousMode(TIMER_A0_BASE, &continuousModeConfig);

/* Enabling interrupts and going to sleep */
Interrupt_enableSleepOnIsrExit();
Interrupt_enableInterrupt(INT_TA0_N);

/* Enabling MASTER interrupts */
Interrupt_enableMaster();

/* Starting the Timer_A0 in continuous mode */
Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_CONTINUOUS_MODE);
int a;
while(1)
{
GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

}

}

void TA0_N_IRQHandler(void)
{
Timer_A_clearInterruptFlag(TIMER_A0_BASE);
GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);

}

跳不出去定时器A中断,没法执行主函数里面的程序。

调试的时候单步执行的时候可以跳出去。但是一运行就不行了

gaoyang9992006:

是你中断函数里干的事情不明显,你应该是想翻转电平吧。你现在做的好像是拉高而已,然后第二次时候你就看不出来了。

gaoyang9992006:

一般是这样的。/* --COPYRIGHT--,BSD_EX* Copyright (c) 2013, 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.**********************************************************************************MSP432 CODE EXAMPLE DISCLAIMER** MSP432 code examples are self-contained low-level programs that typically* demonstrate a single peripheral function or device feature in a highly* concise manner. For this the code may rely on the device's power-on default* register values and settings such as the clock configuration and care must* be taken when combining code from several examples to avoid potential side* effects. Also see www.ti.com/.../mspdriverlib for an API functional* library & https://dev.ti.com/pinmux/ for a GUI approach to peripheral configuration.** --/COPYRIGHT--*/
//******************************************************************************
//MSP432P401 Demo - Timer32 Example, One-shot and periodic mode
//
//Description: Timer 32 (module 0) is set up in 32-bit, periodic mode. Timer
//is configured to count down from a pre-loaded value to 0. Interrupt triggers
//when timer count is equal to 0. Timer32 interrupt service routine (ISR)
//toggles P1.0 LED.
//
//MSP432P401x
//---------------
///|\||
//| ||
//--|RST|
//||
//|P1.0|-->LED
//
//William Goh
//Texas Instruments Inc.
//June 2016 (updated) | November 2013 (created)
//Built with CCSv6.1, IAR, Keil, GCC
//******************************************************************************
#include "msp.h"int main(void)
{WDT_A->CTL = WDT_A_CTL_PW |// Stop WDTWDT_A_CTL_HOLD;// Configure GPIOP1->DIR |= BIT0;P1->OUT &= ~BIT0;// Timer32 set up in periodic mode, 32-bit, no pre-scaleTIMER32_1->CONTROL = TIMER32_CONTROL_SIZE |TIMER32_CONTROL_MODE;// Load Timer32 counter with period = 0x20000TIMER32_1->LOAD= 0x20000;// Enalbe the Timer32 interrupt in NVIC__enable_irq();NVIC->ISER[0] = 1 << ((T32_INT1_IRQn) & 31);// Enable sleep on exit from ISRSCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;// Start Timer32 with interrupt enabledTIMER32_1->CONTROL |= TIMER32_CONTROL_ENABLE |TIMER32_CONTROL_IE;// Enter LPM0;__sleep();// For the debugger when halt is asserted. This is only needed for// debug mode__no_operation();
}void T32_INT1_IRQHandler(void)
{TIMER32_1->INTCLR |= BIT0;// Clear Timer32 interrupt flagP1->OUT ^= BIT0;// Toggle P1.0 LED
}

Susan Yang:

GPIO_setOutputHighOnPin:

This function sets output HIGH on the selected Pin.

这个就是拉高了您现在所选的pin

您现在想在中断服务程序中实现什么功能呢?

赞(0)
未经允许不得转载:TI中文支持网 » MSP432跳不出定时器A中断为什么
分享到: 更多 (0)