/****************************************************************************************************************
*************************
*Author:JYW
*Time:2019_05_15
*Describe:LetAllLinesOfCodeSpeak
*****************************************************/
/*********************************************
**Auther:JYW
*Time:2019_05_15
*Describe:定时器1产生PWM代码练习
************************************/
#include <ioCC2530.h>
typedef unsigned char uchar;
typedef unsigned char uint;
#define LED1 P1_0
void InitLed(void)
{
P1DIR |= 0x01;
LED1 = 1;
}
void InitT1(void)
{
CLKCONCMD &=~0x40;
while(CLKCONSTA & 0x40);
CLKCONCMD &= ~0x07;// 系统主时钟频率
CLKCONCMD |= 0x38;//定时器频率250KHZ
PERCFG |= 0x40;//备用位置2
P2SEL &= ~0x10;//定时器1优先
P2DIR |= 0xC0;//定时器通道2-3
P1SEL |= 0x01;
P1DIR |= 0x01;//通道2
T1CTL =0x02;
//T1CTL2 |= 0x04;
T1CTL2 |=0x1C;//00 01 1 100
T1CC2H = 0x00;
T1CC2L = 0x32;
T1CC0H = 0x00;
T1CC0L = 0xFA;//1ms,周期
}
void main(void)
{
InitLed();
InitT1();
while(1)
{}
}