完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我们正在计划创建PWM RB18/RB19和RB20/RB21 ONDSPIC33 EP128MC502。测试结果是PWM2在RB20/RB21上运行良好。但是在RB18/RB19中没有PWM3输出。测试代码简单,如以下,/PWM设置。PTENP.PTEN=0;//PWM模块被禁用。相位1=0;相位2=0;PDC1=150;PDC2=150;DTR1=DTR2=DTR3=25;AltDTR1=ALTDTR3=25;PWMCON1=pWMCON2=pWMCON3=0x000;//FCLCON1=FCLCON2= FCLCON3= 0x00 03;PTCON2=0;PTCON=0x8000;//使能PWM。PTPH=1000;它们是TDO和TDI。禁用代码中的JTAG。但结果还是一样的。谁知道为什么会这样?谁能给我一些关于这个问题的信息?谢谢,酷乐
以上来自于百度翻译 以下为原文 Hi, We are planing to create PWM at RB18/RB19 and RB20/RB21 on dsPIC33EP128MC502. the testing result is PWM2 works well at RB20/RB21. but there is no PWM3 output at RB18/RB19. the testing code is simple as the below, //PWM Setting. PTCONbits.PTEN = 0; //PWM module is disabled. PTPER=1000; PHASE1 = 0; PHASE2 = 0; PHASE3 = 0; PDC1= 150; PDC2= 150; PDC2= 150; DTR1 = DTR2 = DTR3 = 25; ALTDTR1 = ALTDTR2 = ALTDTR3 = 25; PWMCON1= PWMCON2=PWMCON3=0x0000; // FCLCON1=FCLCON2=FCLCON3=0x0003; PTCON2=0; PTCON=0x8000; //Enable PWM. I find the RB18/RB19 has another function(JTAG). they are TDO and TDI. I disable the JTAG in the begging of code. but the result is still same. who does know why is it so? who can give me some information about this issue? Thanks, -Coolhe |
|
相关推荐
7个回答
|
|
六羟甲基三聚氰胺六甲醚。。。在我的DSPIC33 EP256MC502上,PWM3输出是在RB10和RB11(引脚21和22的28引脚封装)。因为你的芯片和我的数据表一样,我想知道,我的意思是,它是一个16位的芯片。甚至没有RB18,RB19。无论如何,我没有仔细看你的代码,也没有尝试过任何测试它,但是:你的意思是要设置PDC3在最后一个声明?问候,戴夫
以上来自于百度翻译 以下为原文 Hmmm... On my dsPIC33EP256MC502, PWM3 output is on RB10 and RB11 (Pins 21 and 22 of the 28-pin package). Since your chip shares the same data sheet as mine, I'm wondering... I mean, it's a 16-bit chip. Wouldn't even have RB18, RB19. Anyhow, I haven't looked very carefully at your code, and haven't tried any testing with it but: Didn't you mean to set PDC3 in that last statement? Regards, Dave |
|
|
|
如上所述,没有标记为RB18或RB19的PIN。大概您所说的是:PIN 21:TDO/RP42/RB10和PIN 22:TDI/RP43/RB11,您是如何禁用JTAG的?
以上来自于百度翻译 以下为原文 As above, there are no pins labelled RB18 or RB19. Presumably you are talking about: Pin 21: TDO/RP42/RB10 and Pin 22: TDI/RP43/RB11 What exactly did you do to disable JTAG? |
|
|
|
亲爱的DaveKW7X和Qub,抱歉我的TyPo。它应该是PDC3= 150..是的,PWM3应该是PIN 18(RB10)和PIN 19(RB11)。我用下面的代码禁用JTAG。它与软件无关。现在,我可以从这两个引脚得到PWM输出。但新的问题是,我想交换PWM3H和PWM3L,也就是说,如果旧的PWM3H高,旧的PWM3L低,我希望它们的输出是相反的。代码为ICON3BITS,SWAP=1;测试结果为,旧占空比为15%,新占空比仍为15%。也就是说,PWM3H和PWM3L没有交换,事实上,PWM2也是如此。你知道原因吗?谢谢,酷乐
以上来自于百度翻译 以下为原文 Dear Davekw7x and qub, Sorry for my typo. it should be PDC3 =150. Yes, the PWM3 should be Pin 18(RB10) and Pin 19(RB11). I use the below code to disable JTAG. #pragma config JTAGEN=OFF //JTAG Enable bit(JTAG is disabled) The above issue is from hardware. it is not related to software. right now, I can get the PWM output from these two pins. But the new issue is, I would like to swap PWM3H and PWM3L. that's to say, if old PWM3H is High and old PWM3L is low, I would like the output of them is reverse. the code is, IOCON3bits.SWAP=1; The testing result is, the old duty cycle is 15% and the new duty cycle still is 15%. that's to say, there is no swapping of PWM3H and PWM3L. in fact, the PWM2 is also so. do you know the reason for it? Thanks, -Coolhe |
|
|
|
在更改IOCONx之前,您是否发出了需要的解锁序列?如果你这样做了,请发布你的代码的一部分。问候,戴夫
以上来自于百度翻译 以下为原文 Did you issue the unlock sequence that is required before making changes to IOCONx? If you did, please post that part of your code. Regards, Dave |
|
|
|
你好,戴夫,是的,我把PWMKEY解锁为下面的代码。PTENP.PTEN=0;//PWM模块被禁用。PTPH=1000;/ /解锁PWMLOK。CON2= 0x003;pWMKEY=0x4321;IOCON2= 0xC02;/0xF000阶段=0;PdC2=150;PDC3=150;DTR2= DTR3=0;pWMCON2= pWMCON3= 0x000;//PTCON2= 0;PTCON=0x8000;/ /启用PWM。(1);PWMKEY=0xABCD;PWMKEY=0x4321;FCLKC:PWM2的占空比测试结果总是15%。
以上来自于百度翻译 以下为原文 Hi Dave, Yes, I unlock the PWMKEY as the below code. *****************************************************************888 //PWM Setting. PTCONbits.PTEN = 0; //PWM module is disabled. PTPER=1000; //Unlock the PWMLOCK. PWMKEY = 0xabcd; PWMKEY = 0x4321; FCLCON2 = 0x0003; PWMKEY = 0xabcd; PWMKEY = 0x4321; IOCON2 = 0xC002; //0xF000 PHASE2 = 0; PHASE3 = 0; PDC2= 150; PDC3= 150; DTR2 = DTR3 = 0; ALTDTR2 = ALTDTR3 = 0; PWMCON2=PWMCON3=0x0000; // PTCON2=0; PTCON=0x8000; //Enable PWM. while(1); ************************************************* The test result of duty cycle on PWM2 is always 15%. -Coolhe |
|
|
|
我在优化级别0中使用XC16的经验是,这些方法不起作用。编译器在序列中生成的额外指令将PooCh拧紧。在优化级别设置为1(我似乎记得它确实如此)时,它可能会或可能无法工作,但我不指望它。我可以想出几个更合理的方法:做到这一点:这是可以的快速和简单的测试:不需要任何解锁序列。但是在一个“真实”的应用程序中,您可能不想禁用由PWMLIK提供的保护。不小心的占空比变化可能是灾难性的。使用数据表中显示的汇编语言序列。有点笨拙,如果这是唯一的方法,那么它是有效的。(保存最好的最后一个)使用做这个动作的内置函数(在编译器用户指南中查找)这是我的初始化序列的相关部分,然后是我的测试():我可以看到每一秒的占空比变化。在我的DSPIC33 EP256MC502上使用XC16版本1.33,优化级别0和1),戴夫
以上来自于百度翻译 以下为原文 My experience with XC16 in optimization level 0 is that these don't work. Extra instructions that the compiler generates in the sequence screw the pooch. It may or may not work with optimization level set to 1 (I seem to recall that it does), but I wouldn't count on it. I can think of several more reasonable approaches:
// The C assignment sequence doesn't work with XC16 version 1.33, // at optimization level 0, so use the builtin //PWMKEY = 0xABCD; //PWMKEY = 0x4321; //IOCON2 = 0xC000; __builtin_write_PWMSFR(&IOCON2, 0xC000, &PWMKEY); //PWMKEY = 0xABCD; //PWMKEY = 0x4321; //FCLCON2 = 0x0003; __builtin_write_PWMSFR(&FCLCON2, 0x0003, &PWMKEY); // Other initialization stuff Then my test in main(): I can see the duty cycle change every second. // Initialize clock, I/O, Uart, PWM, etc... init_system(); while (1) { uint16_t temp = IOCON2; temp ^= 0x0002; __builtin_write_PWMSFR(&IOCON2, temp, &PWMKEY); //IOCON2 ^= 0x0002; LED1 ^= 1; __delay_ms(1000); } // End of main while(1){} loop (Tested on my dsPIC33EP256MC502 with XC16 version 1.33, optimization level 0 and 1) Regards, Dave |
|
|
|
嗨,戴夫,你真的很专业。你的建议很好。现在,我可以用我的思想灵活地控制PWM输出。再次谢谢。-酷!
以上来自于百度翻译 以下为原文 Hi Dave, You are really professional. your suggestions are good. right now, I can flexibly control the PWM output with my thought. Thank you again. -Cool |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
733浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
505浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 06:08 , Processed in 1.346632 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号