 
					
				
		
 xiangjun_rong
		
			xiangjun_rong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi, Vianney,
Pls refer to the doc, hope it can help you
BR
XiangJun Rong
Hi XiangJun Rong,
Thank you for you help : i will test the code with my cpu !
Best regards
 
					
				
		
 xiangjun_rong
		
			xiangjun_rong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
}
 
					
				
		
 xiangjun_rong
		
			xiangjun_rong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
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
 
					
				
		
 xiangjun_rong
		
			xiangjun_rong
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
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
