关于CC2541 TIM3产生输出比较波形
- 定时器基础配置
- 通道配置
- 比较值配置
TIM3的PWM配置输出比较简单,构成一个简单的PWM发生器,最好选择输出比较模式(101)或(110),通过调整T3CCn来实现通道的占空比。
//Init TIM3 base
T3CTL |= 0xE0;//div = 128
T3CTL &= ~0x08; // Disable Timer 3 overflow interrupts
T3CTL &= ~0x03; // Timer 3 mode = 0 - Free-running
T3CTL |= 0x04;//clr
// EN connected at P1_3
// We will use Timer 3 Channel 0 at alternate location 1
// Channel 0 will Set output on compare, clear on 0xFF(101) and counter will
// count in free-running mode to T3CC0.
P1SEL |= 0x08; // Peripheral function on P1_3
T3CCTL0 &= ~0x40; // Disable channel 0 interrupts
T3CCTL0 |= 0x04; // Ch1 mode = compare
T3CCTL0 |= 0x28; // Ch1 output compare mode = 101: Set output on compare, clear on 0xFF
T3CC0 = 128;