完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
//#include "reg51.h" #include "intrins.h" #define FOSC 18432000L typedef unsigned char BYTE; typedef unsigned int WORD; /*Declare SFR associated with the PCA */ //sfr CCON = 0xD8; //PCA control register //***it CCF0 = CCON^0; //PCA module-0 interrupt flag //***it CCF1 = CCON^1; //PCA module-1 interrupt flag //***it CR = CCON^6; //PCA timer run control bit //***it CF = CCON^7; //PCA timer overflow flag //sfr CMOD = 0xD9; //PCA mode register //sfr CL = 0xE9; //PCA base timer LOW //sfr CH = 0xF9; //PCA base timer HIGH //sfr CCAPM0 = 0xDA; //PCA module-0 mode register //sfr CCAP0L = 0xEA; //PCA module-0 capture register LOW //sfr CCAP0H = 0xFA; //PCA module-0 capture register HIGH //sfr CCAPM1 = 0xDB; //PCA module-1 mode register //sfr CCAP1L = 0xEB; //PCA module-1 capture register LOW //sfr CCAP1H = 0xFB; //PCA module-1 capture register HIGH sfr PCAPWM0 = 0xf2; sfr PCAPWM1 = 0xf3; void main() { CCON = 0; //Initial PCA control register //PCA timer stop running //Clear CF flag //Clear all module interrupt flag CL = 0; //Reset PCA base timer CH = 0; CMOD = 0x02; //Set PCA timer clock source as Fosc/2 //Disable PCA timer overflow interrupt CCAP0H = CCAP0L = 0x80; //PWM0 port output 50% duty cycle square wave CCAPM0 = 0x42; //PCA module-0 work in 8-bit PWM mode and no PCA interrupt CCAP1H = CCAP1L = 0xff; //PWM1 port output 0% duty cycle square wave PCAPWM1 = 0x03; CCAPM1 = 0x42; //PCA module-1 work in 8-bit PWM mode and no PCA interrupt CR = 1; //PCA timer start run //P1M0=0X00; //P1M1=0X08; while (1); } 从哪可以看出哪个IO口输出PWM |
|
相关推荐
2个回答
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
3280 浏览 9 评论
2958 浏览 16 评论
3460 浏览 1 评论
9004 浏览 16 评论
4052 浏览 18 评论
1115浏览 3评论
573浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
571浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2303浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1859浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 13:28 , Processed in 1.258064 second(s), Total 81, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号