主题:CC1350中讨论的其它部件
e2e.ti.com/.../cc1350_5F00_TIMER.c.txte2e.ti.com/.../cc1350_5F00_TIMER.c.txtHi,1350,
我正在使用CC1350启动板进行应用程序开发。 对于我的应用,我需要使用中断的816位计时器。 目前,我配置了4个32位计时器,并中断工作正常。
我配置了4个16位计时器,包括半宽,周期模式,TimerA0, TimerA1, TimerA2, TimerA3也工作正常。
但我无法获得16位半宽计时器中断,定期模式(如TimerA0,TimerB0,
TimerA1,TimerB1, TimerA2,TimerB2和 TimerA3 TimerB3。
这里我得到的是TimerB0, TimerB1, TimerB2, TimerB3中断,但不是 TimerA0, TimerA1, TimerA2, TimerA3中断。 我是否遗漏了附在代码中的任何内容。 任何建议都是值得赞赏的。
/*
主要c
*/
#include <stdint.h>
#include <stddef.h>
包含"Board.h"
#include <NoRTOS.h>
#include <ti/devices/cc13x0/driverlib/prcm.h>
#include <ti/devices/cc13x0/driverlib/gPIO.h>
#include <ti/devices/cc13x0/driverlib/ioc.h>
#include <ti/devices/cc13x0/driverlib/timer.h>
#include <ti/devices/cc13x0/inc/HW_memmap.h>
#include <ti/devices/cc13x0/inc/HW_ints.h>
void led设置(void);
Void Timer_Power_Init (void);
void timer0_a_setup (void);
void timer0_B_setup(void);
void Timer1_a_setup (void);
void Timer1_B_setup(void);
void timer2_a_setup (void);
void timer2_b_setup(void);
void timer3_a_setup (void);
void timer3_b_setup (void);
void timer_A0_ISR(void);
void timer_b0_isr (void);
void timer_a1_isr (void);
void timer_B1_ISR(void);
void timer_a2_isr (void);
void timer_b2_isr (void);
void timer_a3_isr (void);
void timer_B3_isr (void);
//int值;
/*
*========= 主====
*主功能
*/
无符号int值,value1;
内部主(无效)
{
LED_setup();
Timer_Power_Init();
//设置定时器
timer0_a_setup();
Timer1_a_setup();
timer2_a_setup();
timer3_a_setup();
timer0_B_setup();
Timer1_B_setup();
timer2_b_setup();
timer3_b_setup();
//启用主中断
IntMasterEnable();
//永远循环等待中断
for (;;);
返回0;
}
/*
*========= LED_setup =======
*设置红色和绿色LED
*/
void led设置(void)
{
//打开外围域
PRCMPowerDomainOn(PRCM_DOMAIN_Periph);
while (PRCMPowerDomainStatus(PRCM_DOMAIN_Periph)!= PRCM_DOMAIN_POWER_ON);
//打开GPIO外设的电源
PRCMPeripheralRunEnable(PRCM_Periph_GPIO;
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用红色LED的输出
GPIO_setOutputEnableDio (IOID_6,GPIO输出启用);
//打开红色LED
GPIO_setDio (IOID_6);
//启用绿色LED的输出
GPIO_setOutputEnableDio (IOID_7,GPIO输出启用);
//关闭绿色LED
GPIO_clearDio (IOID_7);
GPIO_setOutputEnableDio (IOID_23,GPIO输出启用);
GPIO_setOutputEnableDio (IOID_3,GPIO输出启用);
GPIO_setOutputEnableDio (IOID_25,GPIO输出启用);
GPIO_setOutputEnableDio (IOID_26,GPIO输出启用);
GPIO_setOutputEnableDio (IOID_27,GPIO输出启用);
GPIO_setOutputEnableDio (IOID_28,GPIO输出启用);
}
/*
*========= ISR_TimerInterrup_Handler =========
*中断处理程序,为TIMER_TIMA_TIMEOUT中断提供服务。
*/
void timer_A0_ISR(void)
{
//清除中断标志
TimerIntClear (GPT0_BASE,TIMER_TIMA_TIMEOUT);// 4001万
//切换红色LED
GPIO_toggleDio (IOID_6);
// TimerLoadSet (GPT0_BASE,TIMER_A,0xFFFF);
//////启用中断
// TimerIntEnable(GPT0_base, timer_TIMA_MATCH);
//////启用计时器
// TimerEnable (GPT0_BASE,TIMER_A);
}
void timer_b0_isr (void)
{
//清除中断标志
TimerIntClear (GPT0_BASE,TIMER_TIMB_TIMEOUT);// 4001万
//切换绿色LED
GPIO_toggleDio (IOID_7);
// TimerLoadSet (GPT0_BASE,TIMER_B,0xFFFF);
//////启用中断
// TimerIntEnable (GPT0_BASE,TIMER TIMB_MATCH);
//////启用计时器
// TimerEnable (GPT0_BASE,TIME_B);
}
void timer_a1_isr (void)
{
//清除中断标志
TimerIntClear (GPT1_BASE,TIME_TIMA_TIMEOUT);
//切换红色LED
GPIO_toggleDio (IOID_23);
}
void timer_B1_ISR(void)
{
//清除中断标志
TimerIntClear (GPT1_BASE,TIME_TIMB_TIMEOUT);
//切换绿色LED
GPIO_toggleDio (IOID_3);
}
void timer_A2_isr (void)
{
//清除中断标志
TimerIntClear (GPT2_BASE,TIMER_TIMA_TIMEOUT);
//切换红色LED
GPIO_toggleDio (IOID_25);
}
void timer_b2_isr (void)
{
//清除中断标志
TimerIntClear (GPT2_BASE,TIMER_TIMB_TIMEOUT);
//切换绿色LED
GPIO_toggleDio (IOID_26);
}
void timer_A3_isr (void)
{
//清除中断标志
TimerIntClear (GPT3_BASE,TIMER_TIMA_TIMEOUT);
//切换红色LED
GPIO_toggleDio (IOID_27);
}
void timer_B3_isr (void)
{
//清除中断标志
TimerIntClear (GPT3_BASE,TIMER_TIMB_TIMEOUT);
//切换绿色LED
GPIO_toggleDio (IOID_28);
}
作废Timer_Power_Init (void)
{
//打开外围域
PRCMPowerDomainOn(PRCM_DOMAIN_Periph);
PRCMGPTimerClockDivisionSet (PRCM_Clock_DIV_2);
PRCMLoadSet();
while (!PRCMLoadGEet();
}
//1秒计时器
void timer0_a_setup (void)
{
//步骤1:打开TIMER0外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER0);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER0以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER0);
//配置TIMER0
TimerDisable (GPT0_BASE,TIMER_A);
TimerConfigure(GPT0_base, timer_CFG_Split_pair|timer_CFG_A_Periodic|timer_CFG_B_Periodic);//
// value= TimerValueGet (GPT0_base,timer_a);
// TimerMatchSet (GPT0_BASE,TIMER_A,0x100);
// TimerSynchronize (GPT0_BASE,TIMER_0A_SYNC);
//设置初始计时器值
TimerLoadSet (GPT0_BASE,TIMER_A,0xFFFF);//1sec timer 0xB71B00
//设置预分频器
TimerPrescaleSet (GPT0_BASE,TIMER_A,0x00);
//计时器以在正时钟边缘上计数
TimerEventControl(GPT0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT0_BASE,TIMER_TIMA_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT0_BASE,TIMER_A,TIMER_A0_ISR);
//启用中断
TimerIntEnable(GPT0_base, timer_TIMA_timeout);
//启用计时器
TimerEnable (GPT0_BASE,TIMER_A);
}
void timer0_B_setup (void)
{
//打开TIMER0外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER0);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER0以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER0);
//配置TIMER0
TimerDisable (GPT0_BASE,TIMER_B);
TimerConfigure(GPT0_base, timer_CFG_Split_pair|timer_CFG_A_Periodic|timer_CFG_B_Periodic);//
// TimerMatchSet (GPT0_base,timer_B,0x100);
// TimerSynchronize (GPT0_BASE,TIME_0B_SYNC);
//设置初始计时器值
TimerLoadSet (GPT0_BASE,TIMER_B,0xFFFF);//1秒计时器
//设置预分频器
TimerPrescaleSet (GPT0_BASE,TIMER_B,0x00);
//计时器以在正时钟边缘上计数
TimerEventControl(GPT0_BASE,TIMER_B,TIMER_EVENT_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT0_BASE,TIMER_TIMB_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT0_BASE,TIMER_B,TIMER_B0_ISR);
//启用中断
TimerIntEnable(GPT0_base, timer_TIMB_timeout);
//启用计时器
TimerEnable (GPT0_BASE,TIMER_B);
//value1= TimerValueGet (GPT0_base,timer_B);
}
作废计时器1_a_setup (void)
{
//打开Timer1外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_Timer1);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用Timer1以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_Timer1);
TimerDisable (GPT1_base,timer_a);
//配置Timer1.
TimerConfigure(GPT1_base, timer_CFG_Split_pair|timer_CFG_A_Periodic);
TimerMatchSet (GPT1_base,timer_a,0xFF);
//设置初始计时器值
TimerLoadSet (GPT1_BASE,TIMER_A,0xFFFF);//1sec timer 0xB71B00
//设置预分频器
TimerPrescaleSet (GPT1_base,timer_a,0x00);
//计时器以在正时钟边缘上计数
TimerEventControl(GPT1_base, timer_a, timer_event_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT1_BASE,TIME_TIMA_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT1_BASE,TIMER_A,TIMER_A1_ISR);
//启用中断
TimerIntEnable(GPT1_base, timer_TIMA_timeout);
//启用计时器
TimerEnable(GPT1_base, timer_a);
}
作废时间1_B_setup(void)
{
//打开Timer1外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_Timer1);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用Timer1以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_Timer1);
TimerDisable (GPT1_base,timer_B);
//配置Timer1.
TimerConfigure(GPT1_base, timer_CFG_Split_pair|timer_CFG_B_Periodic);
// TimerMatchSet (GPT1_base,timer_B,0x1FFF);
//设置初始计时器值
TimerLoadSet (GPT1_BASE,TIME_B,0xFFFF);//1秒计时器
//设置预分频器
TimerPrescaleSet (GPT1_base,timer_B,0x0000);
//计时器以在正时钟边缘上计数
// TimerEventControl (GPT1_base,timer_B,timer_event_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT1_BASE,TIME_TIMB_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT1_BASE,TIMER_B,TIMER_B1_ISR);
//启用中断
TimerIntEnable(GPT1_base, timer_TIMB_timeout);
//启用计时器
TimerEnable (GPT1_BASE,TIME_B);
}
void timer2_a_setup (void)
{
//打开TIMER2外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER2);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER2以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER2);
TimerDisable (GPT2_BASE,TIMER_A);
//配置TIMER2
TimerConfigure(GPT2_base, timer_CFG_Split_pair|timer_CFG_A_Periodic);
// TimerMatchSet (GPT2_BASE,TIMER_A,0xFF);
//设置初始计时器值
TimerLoadSet (GPT2_BASE,TIMER_A,0xFFFF);//1sec timer 0xB71B00
//设置预分频器
TimerPrescaleSet (GPT2_BASE,TIMER_A,0x00);
//计时器以在正时钟边缘上计数
// TimerEventControl (GPT2_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT2_BASE,TIMER_TIMA_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT2_BASE,TIMER_A,TIMER_A2_ISR);
//启用中断
TimerIntEnable(GPT2_base, timer_TIMA_timeout);
//启用计时器
TimerEnable (GPT2_BASE,TIMER_A);
}
作废计时器2_B_setup(void)
{
//打开TIMER2外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER2);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER2以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER2);
TimerDisable (GPT2_BASE,TIMER_B);
//配置TIMER2
TimerConfigure(GPT2_base, timer_CFG_Split_pair|timer_CFG_B_Periodic);
TimerMatchSet (GPT2_BASE,TIMER_B,0xFF);
//设置初始计时器值
TimerLoadSet (GPT2_BASE,TIMER_B,0xFFFF);//1秒计时器
//设置预分频器
TimerPrescaleSet (GPT2_BASE,TIMER_B,0x00);
//计时器以在正时钟边缘上计数
// TimerEventControl (GPT2_BASE,TIMER_B,TIMER_EVENT_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT2_BASE,TIMER_TIMB_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT2_BASE,TIMER_B,TIMER_B2_ISR);
//启用中断
TimerIntEnable(GPT2_base, timer_TIMB_timeout);
//启用计时器
TimerEnable (GPT2_BASE,TIMER_B);
}
作废计时器3_a_setup (void)
{
//打开TIMER3外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER3);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER3以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER3);
TimerDisable (GPT3_BASE,TIMER_A);
//配置TIMER3
TimerConfigure(GPT3_base, timer_CFG_Split_pair|timer_CFG_A_Periodic);
// TimerMatchSet (GPT3_base,timer_a,0xFF);
//设置初始计时器值
TimerLoadSet (GPT3_base,timer_a,0xFFFF);//1sec timer 0xB71B00
//设置预分频器
TimerPrescaleSet (GPT3_base,timer_A,0x00);
//计时器以在正时钟边缘上计数
// TimerEventControl (GPT3_base,timer_a,timer_event_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT3_BASE,TIMER_TIMA_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT3_BASE,TIMER_A,TIMER_A3_ISR);
//启用中断
TimerIntEnable(GPT3_base, timer_TIMA_timeout);
//启用计时器
TimerEnable (GPT3_BASE,TIMER_A);
}
作废计时器3_B_setup (作废)
{
//打开TIMER3外围设备的电源
PRCMPeripheralRunEnable(PRCM_Periph_TIMER3);
PRCMLoadSet();
while (!PRCMLoadGEet();
//启用TIMER3以在MCU休眠时继续计数
PRCMPeripheralSleepEnable (PRCM_Periph_TIMER3);
TimerDisable (GPT3_BASE,TIMER_B);
//配置TIMER3
TimerConfigure(GPT3_base, timer_CFG_Split_pair|timer_CFG_B_Periodic);
// TimerMatchSet (GPT3_base,timer_B,0xFF);
//设置初始计时器值
TimerLoadSet (GPT3_BASE,TIME_B,0xFFFF);//1秒计时器
//设置预分频器
TimerPrescaleSet (GPT3_base,timer_B,0x00);
//计时器以在正时钟边缘上计数
// TimerEventControl (GPT3_base,timer_B,timer_event_POS_EDGE);
//确保中断可以开始
TimerIntClear (GPT3_BASE,TIMER_TIMB_TIMEOUT);
//指定中断处理程序
TimerIntRegister (GPT3_BASE,TIMER_B,TIMER_B3_ISR);
//启用中断
TimerIntEnable (GPT3_BASE,TIMER_TIMB_TIMEOUT);
//启用计时器
TimerEnable (GPT3_BASE,TIME_B);
}