完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我有一个奇怪的问题-当我配置RB8的开路漏控制,所有PWM发生器从外围断开。我使用DSPIC33 EP64 GS506和MPLAB与XC16编译器。当我尝试使用I2C2模块进行通信时,我首先注意到这一点(RB8是SDA2)。我尝试了所有其他的I2C引脚,它们不影响PWM发生器。这里是一个最小的(非)工作例子:
以上来自于百度翻译 以下为原文 Hi everyone, I have a bizarre problem - when I configure RB8 for open-drain control, all PWM generators are disconnected from the peripheral. I use dsPIC33EP64GS506, and MPLAB with xc16 compiler. I've first noticed this when I tried to use I2C2 module for communication (RB8 is SDA2). I tried with all other I2C pins, they don't affect PWM generators. Here is a minimum (non)working example: #pragma config BWRP=OFF, BSS=DISABLED, BSEN=OFF, GWRP=OFF, GSS=DISABLED, CWRP=OFF, CSS=DISABLED, AIVTDIS=OFF #pragma config FNOSC=FRC, IESO=OFF #pragma config POSCMD=XT, OSCIOFNC=OFF, IOL1WAY=ON, FCKSM=CSECMD, PLLKEN=ON #pragma config WDTPOST=PS32768, WDTPRE=PR128, WDTEN=OFF, WINDIS=OFF, WDTWIN=WIN25 #pragma config ICS=PGD1, JTAGEN=OFF, BTSWP=OFF #pragma config CTXT1=OFF, CTXT2=OFF #pragma config PWMLOCK=OFF, DBCC=OFF // Use only one of these two configurations: // OFF - I2C module is mapped to SDA/SCL pins // ON - I2C module is mapped to ASDA/ASCL pins #pragma config ALTI2C1=OFF, ALTI2C2=ON #include #define FCY 30000000UL #include int main(void) { //=== INITIALIZE OSCILLATOR ===// // 10 MHz -> PLL -> 120 MHz (FPLL) // FCY is 60 MHz (30 MIPS) // PLL parameters _PLLPRE = 0; // N1=2 PLLFBD = 22; // M=24 _PLLPOST = 0; // N2=2 // Initiate clock switch sequence __builtin_write_OSCCONH(0x03); __builtin_write_OSCCONL(OSCCON | 0x01); // Wait until clock switch occurs while (OSCCONbits.COSC != OSCCONbits.NOSC); while (OSCCONbits.LOCK == 0); // PWM clock source is FPLL ACLKCONbits.SELACLK = 0; ACLKCONbits.APSTSCLR = 7; // divide-by-1 while (ACLKCONbits.APLLCK == 0); //=== INITIALIZE PORTS ===// // Configure all I2C ports for open-drain output // Configure all other ports for digital output // All ports are digital (not analog) ANSELA = 0x0000; ANSELB = 0x0000; ANSELC = 0x0000; ANSELD = 0x0000; // Initialize all LAT ports to low state LATA = 0x0000; LATB = 0x0000; LATC = 0x0000; LATD = 0x0000; // Configure all I2C ports // You don't need to use I2C modules // to see what is the problem here // SCL2 _LATB15 = 1; _ODCB15 = 1; // // SDA2 (problem) // _LATB8 = 1; // _ODCB8 = 1; // SDA1 _LATB7 = 1; _ODCB7 = 1; // SCL1 _LATB6 = 1; _ODCB6 = 1; // ASCL2 _LATB3 = 1; _ODCB3 = 1; // ASDA2 _LATC15 = 1; _ODCC15 = 1; // ASCL1 _LATC8 = 1; _ODCC8 = 1; // ASDA1 _LATC7 = 1; _ODCC7 = 1; // All other ports are digital outputs TRISA = 0x0000; TRISB = 0x0000; TRISC = 0x0000; TRISD = 0x0000; //=== INITIALIZE PWM MODULE ===// // Configure for 50 kHz operation with 50% duty-cycle // Use a master time base for all PWM generators PTCON = 0x0000; PTCON2 = 0x0000; // divide-by-1 // PWM timing configuration PTPER = 19192; // 50 kHz, 20 us PDC1 = 9600; // 50% PDC2 = 9600; // 50% PDC3 = 9600; // 50% PDC4 = 9600; // 50% PDC5 = 9600; // 50% _PTEN = 1; // enable PWM //=== INITIALIZE I2C MODULE ===// // I2C1 module configuration // This one doesn't affect PWM generators, // regardless on ALTI2C1 configuration I2C1CONL = 0x9040; I2C1ADD = 0x50; I2C1MSK = 0x0000; // I2C2 module configuration // Note that this one will affect PWM generators // if you don't set ALTI2C2=ON I2C2CONL = 0x9040; I2C2ADD = 0x50; I2C2MSK = 0x0000; //=== INFINITE LOOP ===// while (1); return 0; } EDIT: In addition to this, it seems that I cannot configure RB8 as digital input either. If I configure RB8 as digital input, PWM stops working. |
|
相关推荐
4个回答
|
|
你检查了芯片的勘误表了吗?这是强制性的提交一个“案例”的微芯片技术支持。去Microchip站点,去技术支持,注册“我的Microchip”账户并填写一个“案例”。这是最有效的,当你可以提供支持的例子项目,你肯定有。
以上来自于百度翻译 以下为原文 Did you check the Errata for your chip? It's mandatory to submit a "case" for Microchip tech support. Go to Microchip site, go to tech support, register "My Microchip" account and fill a "case". It is most effective when you can provide the support with example project you certainly have. |
|
|
|
是的,我检查了勘误表,这个问题没有提到。我已经在Microchip TealPosig公司发了一张罚单。
以上来自于百度翻译 以下为原文 Yes, I've checked Errata, this problem is not mentioned. I've already raised a ticket at Microchip tech support. MG |
|
|
|
如果你买了一张票,如果你没有回信,24小时后你需要打电话。这会推动你的车票。
以上来自于百度翻译 以下为原文 If you raised a ticket you need to call after 24 hours if you have not heard back. This will push your ticket. |
|
|
|
谢谢你的建议,但这并不那么重要,也就是说我不需要马上回答。我已经将这些端口重新连接到另一个I2C模块。我会在这里提交他们的答案。
以上来自于百度翻译 以下为原文 Thanks for the suggestion, but it is not that critical, i.e. I don't need the answer right away. I've rewired these ports to another I2C module. I'll submit their answer here. |
|
|
|
只有小组成员才能发言,加入小组>>
5188 浏览 9 评论
2009 浏览 8 评论
1933 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3181 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2232 浏览 5 评论
743浏览 1评论
629浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
512浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
642浏览 0评论
538浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 17:34 , Processed in 1.422132 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号