cc2530 pwm的問題
這是我在TI網站上找到的code
PERCFG &= ~0x40; //select Timer 1 Alternative at Port 0 Location
PERCFG |= 0x03; //Move USART0 and USART1 to Alternative 2 Location
P2DIR = (P2DIR & ~0xC0) | 0X80; //Give priority to Timer 1
P0SEL |= 0x08; // SET P0_3 AS PERIPHERAL
T1CC0L = 0xFF; //PWM signal period
T1CC0H = 0x7F;
T1CC1L = 0x00; //PWM Duty Cycle, Channel 1 (P0_3)
T1CC1H = 0x01;
T1CCTL1 = 0x34; //Channel 1 in compare Mode, Set output on Compare down,
T1CTL |= 0x01; //Start the timer in free running Mode
但是我測出來的頻率都只有227Hz
請問要怎麼把頻率拉高呢?
大約在30k Hz附近就可以了
謝謝各位。
可以对时钟进行分频
可以教我怎麼用嗎?
謝謝您!
你好,我的代码和楼主的类似,测出是250Hz左右,需要得到10KHz左右的频率,请问该如何分频?
// Configure Timer 1 setting
PERCFG = (PERCFG & ~0x40) | 0x03; // Select Timer 1 Alternative 0 location, set U1CFG and U0CFG to Alternative 1 location
P2DIR |= 0xC0; // Give priority to Timer 1
P0SEL |= 0x18; // Set P0.3, P0.4 to peripheral
T1CTL |= 0x02; // to do Modulo Mode
T1CC0L = 0xFF; // PWM signal period
T1CC0H = 0x00;
T1CC1L = 0x7F;
T1CC1H = 0x00;
T1CC2L = 0x7F;
T1CC2H = 0x00;
T1CCTL1 = 0x34;
T1CCTL2 = 0x34;
设置
CLKCONCMD寄存器