PWM configuration

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

PWM configuration

73 Views
scoottroop
Contributor II

Hello everyone! I'm having some trouble with how to configure my PWM signal.

I have the LPCxpresso55s69 EVK.

Current state: Currently my program uses a few outputs and updates, outputting a PWM signal according to a calculated duty cycle, + a directly inverted signal.  Currently I am using the default PWM configuration as seen in the  "sctimer_update_dutycycle" example. The next step is to add two more signals, same as the first two I have created but having a slight dead time (The end goal is a full bridge configuration). 
I've therefore tried to configure the "sctimer_update_dutycycle" to learn how to do this but I'm stuck. I've tried looking in the "AN11538", but it made me a bit confused, so my (probably dumb) questions are: Should I do as in the manual and code the specific registers/bits or is there an easier way using the libraries. I'm currently using the SCtimer library, as in the examples. Am I missing some other important libraries?

Is there any way to make the code in the "AN11538" work on the LPC55S69, it would make it a lot easier for me to understand the whole concept if I could follow those examples.

I understand that I have to use different event and match registers. Again, I'm wondering if there are any libraries for this instead of coding it by hand as in the AN11538 manual. I can't seem to find it. 

Finally I have tried to just configure the PWM myself without using the default. When I try to use anything but the unified counter the program crashes, why? For dead time control I guess I need two, low counters just as in the example instead of the 32 bit counter.
An example of what I tested to configure is in the notepad I included, nothing else is altered so it should work to just copy the code from there. 

Sorry for the probably confusing questions!


Tags (2)
0 Kudos
Reply
3 Replies

53 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

ON my opinion, as you want to generate complementary PWM signals with SCTimer/PWM module, I suggest you write SCTimer/PWM register directly based on AN11538.pdf, which has the code, writing register is direct and straightforward.

calling the SDK driver is complex.

Pls refer to the community ticket for writing the SCTimer register.

https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/Generating-phase-shift-PWM-signal-with-S...

 

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply

42 Views
scoottroop
Contributor II

Hey! thank you for the reply!

I still don't understand quite though. I looked thorugh the example but i'm still not sure how to look up how to write to the registers on my specific EVK. If i try to use the example you linked, there are still some uninitiated variables such as EVENT and SCT_Type. It may be a stupud question but do i need to initiate these variables in some way, or am i using the wrong name in the case of my EVK? 
I'm having a lot of errors and i don't know what i'm supposed to do, maybe you can have a quick look and see what i'm doing wrong? how do i use the example you sent and adapt it to the LPCxpresso55S69 EVK? 

 

 

Thank you again!

0 Kudos
Reply

32 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding the error of compilation, Pls refer to the lpc55s69_cm33_core0.h for the register architecture.

I have changed part of the code, it can pass the compilation.

The following code can pass the compilation.

Hope it can help you

BR

Xiangjun rong

 

 

void SCT0_PWM(void)

{

SYSCON->AHBCLKCTRLX[1]|=(1<<2); //SET SCT0 bit

//configure the SCT clock source

SYSCON->SCTCLKSEL=0; //main clock is the SCT driving clock

SCT0->CONFIG = (1 << 0) | (1 << 17); // unified 32-bit timer, auto limit

SCT0->MATCHREL[0] = SystemCoreClock/100; // match 0 @ 100 Hz = 10 msec

SCT0->EV[0].STATE = 0xFFFFFFFF; // event 0 happens in all states

 

 

//set event1

SCT0->MATCHREL[1]=0x00;

SCT0->EV[1].STATE = 0xFFFFFFFF; // event 1 happens in all states

SCT0->EV[1].CTRL = (1 << 12)|(1<<0); // match 1 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

}

 

//Pin initialization code:

 

//PIO0_8 PIO0_8 FC2_RXD_SDA_MOSI SCT0_OUT1 CTIMER0_MAT3

//PIO0_9 PIO0_9 FC2_TXD_SCL_MISO SCT0_OUT2 CTIMER3_CAP0 - FC3_CTS_SDA_SSEL0

 

void SCTimerPinInit(void)

{

//Enable the SCTimer clock

SYSCON->AHBCLKCTRLX[0]|=(1<<13); //set IOCON bit

 

 

//SCTimer pin assignment

 

IOCON->PIO[0][18]=0x104;

IOCON->PIO[0][19]=0x104;

IOCON->PIO[0][20]=0x104;

}

 

 

 

0 Kudos
Reply