#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_timer.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#define freq 50
#define Period 80000000/freq
#define SERVO_MICROS_MAX 2000
#define SERVO_MICROS_MIN 1000
int setAngle(int angle);
void
WTIMER0IntHandler()
{
TimerIntClear(WTIMER0_BASE,TIMER_CAPB_MATCH);
TimerDisable(WTIMER0_BASE,TIMER_B);
}
int
main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);
IntMasterEnable();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinConfigure(GPIO_PC5_WT0CCP1);
GPIOPinTypeTimer(GPIO_PORTC_BASE, GPIO_PIN_5);
TimerConfigure(WTIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PWM );
TimerLoadSet(WTIMER0_BASE, TIMER_B, Period-1);
setAngle(30);
TimerIntEnable(WTIMER0_BASE, TIMER_CAPB_MATCH);
TimerIntRegister(WTIMER0_BASE, TIMER_B, WTIMER0IntHandler);
TimerEnable(WTIMER0_BASE, TIMER_B);
while(1)
{
printf("...");
}
}
int
setAngle(int angle)
{
uint16_t micros = (SERVO_MICROS_MAX - SERVO_MICROS_MIN) * angle / 180 + SERVO_MICROS_MIN;
uint32_t per = Period - 1 - (micros*80);
TimerMatchSet(WTIMER0_BASE, TIMER_B, per);
return per;
}
This is my code, I can not get the interrupt to work.