//*****************************************************************************
//
// pwm.c - Example demonstra
ting timer-based PWM on a 16-bit CCP.
//
// Copyright (c) 2010-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 Stellaris Firmware Development Package.
//
//*****************************************************************************
/*PB5(TIMER1_B)产生PWM并且是正常的,配置PB1(TIMER2_B)捕获产生pwm的下降沿,但是中断函数一直进不去啊,设置断点发现进不去,求助,问题出在哪里,*/(已经在startup_ccs.c中注册了中断函数)
#ifndef PART_LM4F120H5QR
#define PART_LM4F120H5QR
#endif
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_timer.h"
#include "inc/hw_ints.h"
#include "inc/hw_gpio.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "utils/uartstdio.h"
#include "driverlib/pin_map.h"
//*****************************************************************************
//
// Configure Timer1B as a 16-bit PWM with a duty cycle of 66%.
//
//*****************************************************************************
int i=0;
void Timer2BIntHandler(void);
int main(void)
[
//
// Set the clocking to run directly from the external crystal/oscillator.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// The Timer1 peripheral must be enabled for use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
//
// For this example CCP1 is used with port B pin 5.
// The actual port and pins used may be different on your part, consult
// the data sheet for more information.
// GPIO port B needs to be enabled so these pins can be used.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Configure the GPIO pin muxing for the Timer/CCP function.
// This is only necessary if your part supports GPIO pin function muxing.
// Study the data sheet to see which functions are allocated per pin.
//
GPIOPinConfigure(GPIO_PB5_T1CCP1);
GPIOPinConfigure(GPIO_PB1_T2CCP1);
//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for Timer/PWM operation.
//
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_5);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_1);
//
// Configure Timer1B as a 16-bit periodic timer.
//
TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR |
TIMER_CFG_B_PWM);
TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR |
TIMER_CFG_B_CAP_COUNT);
//
// Set the Timer1B load value to 50000. For this example a 66% duty
// cycle PWM signal will be generated. From the load value (i.e. 50000)
// down to match value (set below) the signal will be high. From the
// match value to 0 the timer will be low.
//
TimerLoadSet(TIMER1_BASE, TIMER_B, 40000);
TimerLoadSet(TIMER2_BASE, TIMER_B, 1);
TimerControlEvent(TIMER2_BASE,TIMER_B,TIMER_EVENT_NEG_EDGE);
//
// Set the Timer1B match value to load value / 3.
//
TimerMatchSet(TIMER1_BASE, TIMER_B, TimerLoadGet(TIMER1_BASE, TIMER_B) / 2);
TimerMatchSet(TIMER2_BASE, TIMER_B, 1);
//
// Enable Timer1B.
//
IntMasterEnable();
TimerEnable(TIMER1_BASE, TIMER_B);
TimerIntEnable(TIMER2_BASE, TIMER_CAPB_EVENT);
IntEnable(INT_TIMER2B);
TimerEnable(TIMER2_BASE, TIMER_B);
TimerIntRegister(TIMER2_BASE, TIMER_B,Timer2BIntHandler);
//
// Loop forever while the Timer1B PWM runs.
//
while(1)
[
;
]
]
void Timer2BIntHandler(void)
[
i++;
if(i==10000)
[
i=0;
]
]
PB5(TIMER1_B)产生PWM并且是正常的,配置PB1(TIMER2_B)捕获产生pwm的下降沿,但是中断函数一直进不去啊,设置断点发现进不去,求助,问题出在哪里,
0