高级会员
- 积分
- 637
- 威望
- 463
- 贡献
- 104
- 兑换币
- 2
- 注册时间
- 2011-1-20
- 在线时间
- 35 小时
|
1贡献
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
void PLL_init(){
REFDV=1; //ËøÏ໷ʱÖÓ=2*16*£¨SYNR+1)/(REFDV+1)=48M
SYNR=2; //×ÜÏßʱÖÓ=48/2=24
while(!(CRGFLG&0X08))
CLKSEL=0x80;
}
void PWM_dj_init() {
PWME_PWME1=0x00;
PWMCTL_CON01=1; //0ºÍ1¼¶Áª
PWMPRCLK=0x33; //¶ÔCLKA½øÐÐ8·ÖƵ A=3M£¬¶ÔCLKB½øÐÐ8·ÖƵ A=3M
PWMSCLA=150; //CLKSA=A/2/PWMSCLA=3M/2/15=10KHz
PWMCLK_PCLK1=1; //Ñ¡ÔñCLKSA×÷ΪʱÖÓÔ´
PWMPOL=0xff; //ÏÈÊä³ö¸ßµçƽ£¬¼ÆÊýµ½DTYʱ£¬·­×ªµçѹ
PWMCAE_CAE1=0; //Ïò×ó¶ÔÆëµÄÊä³öģʽ
PWMPER1=200; //ÖÜÆÚΪ20ms£¬ÆµÂÊΪ50Hz
PWMDTY1=15; //Êä³ö¸ßµçƽʱ¼äΪ1.5ms
PWMCNT01=0; //¼ÆÊýÆ÷ÇåÁã
PWME_PWME1=1;
}
void main(void) {
PLL_init();
PWM_dj_init();
for(;;) {
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
} |
|