cc2540 Timer3 通道1输出比较模式产生PWM波
大家好,我想用cc2540定时器3的通道1的输出比较模式产生38kHz的PWM波,程序如下。但是通道1始终输出高电平,请各位解答,谢谢!
#include<ioCC2540.h>
typedef unsigned char uint8;
#define BV(x) (1<<(x))
void InitTimer3()
{
T3CTL=0x2A;
//溢出中断
//2分频,8M
//modulo mode
T3CC0=0xD2;
T3CC1=0x46; //38kHz,33%占空比
PERCFG |= BV(5);
T3CCTL1=0x64;
//通道1设置
P1DIR |= BV(7);
P1SEL |= BV(7); //p1.7外设,输出
T3CTL |= BV(4); //start timer3
T3IE=1;
EA=1; //开启中断
}
#pragma vector = T3_VECTOR
__interrupt void Timer3_ISR(void)
{
IRCON=0x00;
}
void main(void)
{
InitTimer3();
while(1)
{ }
}
请参考下这边的例程: http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/t/21018.aspx