This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

dpwm frequency error of ucd3138

Other Parts Discussed in Thread: UCD3138

Hi,

I am using ucd3138 to generate a dpwm signal(200KHZ), dpwm0.

However, the frequency is about 170KHZ when the ucd3138 is powered on, and the frequency gradually increased to 200KHZ, which time is about 1s.

I find the problem through the scope. and my codes are as follows:

    Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 0;


    Dpwm0Regs.DPWMCTRL1.bit.GLOBAL_PERIOD_EN = 1;

    Dpwm0Regs.DPWMEV1.all = 0;

    Dpwm0Regs.DPWMEV2.all = 1000;

    Dpwm0Regs.DPWMEV3.all = 10000;

    Dpwm0Regs.DPWMEV4.all = Dpwm0Regs.DPWMEV3.all + Dpwm0Regs.DPWMEV2.all;   

    Dpwm0Regs.DPWMCTRL0.bit.CLA_EN = 0;

    Dpwm0Regs.DPWMCTRL2.bit.SAMPLE_TRIG_1_EN = 0;

    Dpwm0Regs.DPWMCTRL1.bit.EVENT_UP_SEL = 1;

    Dpwm0Regs.DPWMCTRL0.bit.PWM_MODE = 0;

    Dpwm0Regs.DPWMINT.bit.PRD_INT_EN = 0;

    Dpwm0Regs.DPWMINT.bit.PRD_INT_SCALE = 0;

    Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 1;

Thanks. I am looking forward to your reply!

Michael.

  • Hi Michael,

    In your code, I do not find the configuration of DPWM period, you can refer to below code for the configuration.

    Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 0; //disable locally for init
    Dpwm0Regs.DPWMCTRL0.bit.CLA_EN = 0; //default is 1 - use cla

    Dpwm0Regs.DPWMPRD.all = PERIOD; //use .all for all values, make sure scaling matches.
    Dpwm0Regs.DPWMEV1.all = 0; //Put event 1 at start of period
    Dpwm0Regs.DPWMEV2.all = PERIOD/4; //1/4 of period - divide is OK because it's all constants.
    Dpwm0Regs.DPWMEV3.all = PERIOD/2; //1/2 of period
    Dpwm0Regs.DPWMEV4.all = (PERIOD * 3)/4; //3/4 of period

    Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 1; //enable locally
    LoopMuxRegs.GLBEN.bit.DPWM0_EN = 1; //enable globally

    Best Regards

    Frank

  • Thanks, Frank.

    The problem is solved using the bit HFO_LN_FILTER_EN =0.