想使用定时器的PWM模式功能,但是发现开启了PWM模式后,定时器超时中断无法进入了,这是什么原因呢,pwm输出已经可以了,代码如下
//*****************************************************************************
//
// project0.c - Example to demonstrate minimal StellarisWare setup
//
// Copyright (c) 2012 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 9453 of the EK-LM4F120XL Firmware Package.
//
//*****************************************************************************
#include "inc/hw_ints.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/rom.h"
#include "driverlib/interrupt.h"
//*****************************************************************************
//
// Define pin to LED color mapping.
//
//*****************************************************************************
#define RED_LED GPIO_PIN_1
#define BLUE_LED GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3
//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Project Zero (project0)</h1>
//!
//! This example demonstrates the use of StellarisWare to setup the clocks
//! and toggle GPIO pins to make the LED's blink. This is a good place to
//! start understanding your launchpad and the tools that can be used to
//! program it. See http://www.ti.com/stellaris-launchpad/project0 for more
//! information and tutorial videos.
//!
//
//*****************************************************************************
unsigned long clockfre;
unsigned char bit;
void Timer0IntHandler(void)
{
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ROM_TimerMatchSet(TIMER0_BASE, TIMER_A, 1000);
}
//*****************************************************************************
//
// Main 'C' Language entry point. Toggle an LED using StellarisWare.
// See www.ti.com/stellaris-launchpad/project0 for more information and
// tutorial videos.
//
//*****************************************************************************
int
main(void)
{
ROM_FPULazyStackingEnable();
//设置系统频率为80Mhz
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|
SYSCTL_OSC_MAIN);
//使能定时器0 32/16bit时钟模块
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//设置Timer0-A模块为PWM输出模式
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR |TIMER_CFG_A_PWM);
//读取系统频率
clockfre=ROM_SysCtlClockGet();
// 设置定时器的计数值,10khz
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, 8000);
ROM_TimerMatchSet(TIMER0_BASE, TIMER_A, 6000);
// 启用系统总中断开关
ROM_IntMasterEnable();
// 在系统层面(NVIC)使能Timer0-A中断
ROM_IntEnable(INT_TIMER0A);
//使能定时器0,定时器A超时中断
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB6_T0CCP0);
ROM_GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_1);
//使能定时器0,定时器A
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
while(1)
{
}
}