Microchip
直播中

h1654155275.6260

8年用户 217经验值
私信 关注
[问答]

开漏端口阻塞所有PWM发生器从外围断开

大家好,我有一个奇怪的问题-当我配置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)

杜元晓

2019-4-25 11:25:19
你检查了芯片的勘误表了吗?这是强制性的提交一个“案例”的微芯片技术支持。去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.
举报

李明烨

2019-4-25 11:41:25
是的,我检查了勘误表,这个问题没有提到。我已经在Microchip TealPosig公司发了一张罚单。

以上来自于百度翻译


      以下为原文

    Yes, I've checked Errata, this problem is not mentioned.
I've already raised a ticket at Microchip tech support.
MG
举报

陈晨

2019-4-25 12:01:10
如果你买了一张票,如果你没有回信,24小时后你需要打电话。这会推动你的车票。

以上来自于百度翻译


      以下为原文

    If you raised a ticket you need to call after 24 hours if you have not heard back. This will push your ticket.
举报

李明烨

2019-4-25 12:18:08
谢谢你的建议,但这并不那么重要,也就是说我不需要马上回答。我已经将这些端口重新连接到另一个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.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分