lpc 4337 Phase-shift PWM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lpc 4337 Phase-shift PWM

1,421 Views
vianneyfenart
Contributor II

hi,

Is it possible to do a phase shift pwm with SCT of lpc 4337 mcu?

thanks

Labels (2)
7 Replies

1,099 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vianney,

Pls refer to the doc, hope it can help you

BR

XiangJun Rong

https://community.nxp.com/docs/DOC-343979 

1,099 Views
vianneyfenart
Contributor II

Hi XiangJun Rong,

Thank you for you help : i will test the code with my cpu !

Best regards

0 Kudos

1,099 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vianney,

I have developed a simple code to implement the phase shift for two PWM signal based on LPC54114, I attach the code, but you have to modify it based on the LPC4337, for example AHBCLKCTRL register for enabling gated clock and pin assignment.

Hope it can help you

BR

XiangJun Rong

//The SCT0_OUT1 can output PWM signal with 50 duty cycle from PIO0_8 pin
//The SCT_OUT2 can output PWM signal with 50 duty cycle fron PIO0_9 pin
//The SCT0_OUT1 and SCT0_OUT2 PWM signal has 90 degree phase shift.

void SCT0_PWM(void)
{
    SYSCON->AHBCLKCTRL[1]|=(1<<2); //SET SCT0 bit
    SCT0->CONFIG = (1 << 0) | (1 << 17); // unified 32-bit timer, auto limit
    SCT0->SCTMATCHREL[0] = SystemCoreClock/100; // match 0 @ 100 Hz = 10 msec
    SCT0->EVENT[0].STATE = 0xFFFFFFFF; // event 0 happens in all states


    //set event1
    SCT0->SCTMATCHREL[1]=0x00;
    SCT0->EVENT[1].STATE = 0xFFFFFFFF; // event 1 happens in all states
    SCT0->EVENT[1].CTRL = (1 << 12)|(1<<0); // match 1 condition only

    //set event2
    SCT0->SCTMATCHREL[2]=(SystemCoreClock/100)/2;
    SCT0->EVENT[2].STATE = 0xFFFFFFFF; // event 2 happens in all states
    SCT0->EVENT[2].CTRL = (1 << 12)|(2<<0); // match 2 condition only

    //set event3
    SCT0->SCTMATCHREL[3]=(SystemCoreClock/100)/4;
    SCT0->EVENT[3].STATE = 0xFFFFFFFF; // event 3 happens in all states
    SCT0->EVENT[3].CTRL = (1 << 12)|(3<<0); // match 3 condition only

    //set event4
    SCT0->SCTMATCHREL[4]=3*(SystemCoreClock/100)/4;
    SCT0->EVENT[4].STATE = 0xFFFFFFFF; // event 4 happens in all states
    SCT0->EVENT[4].CTRL = (1 << 12)|(4<<0); // match 4 condition only

    //PWM output1 signal
    SCT0->OUT[1].SET = (1 << 1); // event 1 will set SCT1_OUT0
    SCT0->OUT[1].CLR = (1 << 2); // event 2 will clear SCT1_OUT0
    SCT0->RES |= (3 << 2); // output 0 toggles on conflict

    //PWM output2 signal
    SCT0->OUT[2].SET = (1 << 3); // event 3 will set SCT1_OUT0
    SCT0->OUT[2].CLR = (1 << 4); // event 4 will clear SCT1_OUT0
    SCT0->RES = (3 << 4); // output 0 toggles on conflict

    //PWM start
    SCT0->CTRL &= ~(1 << 2); // unhalt by clearing bit 2 of the CTRL
}

1,099 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Viuanney,

Can you refer to the ticket in the community which talks about the phase-shift feature of PWM signals.

https://community.nxp.com/message/765201?commentID=765201#comment-765201

Hope it can help you

BR

Xiangjun Rong

1,099 Views
vianneyfenart
Contributor II

Hi, xiangjun.rong,

thanks for your reply.

i read the post.

if i understand for doing a shift i need to put the first OUPUT PWM to an INPUT PIN for second OUTPUT PWM?

i need to shift 10 output pwm....

best regards

0 Kudos

1,099 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vianney,

I think the user code for the PWM shift is too complicated, you can use a simple way to implement it.

Can you clarify your required PWM shift signal timing? do you need complementary PWM signal with deadtime?

BR

Xiangjun Rong

0 Kudos

1,099 Views
vianneyfenart
Contributor II

Hi, xiangjun.rong,

In fact i only need to shift each pwm signal of few milliseconds....i don't need complementary pwm with deadtime.

actually i use 10 SCT pinout and all signal are synchronous....

can you help me please?

best regards

0 Kudos