LPC55s69 - CTIMER interrupt initialization in PWM mode BUG

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

LPC55s69 - CTIMER interrupt initialization in PWM mode BUG

6,920 Views
danielkrol
Contributor III

Hello,

There is some bug in Config Tools for LPC55s69. Check box "Enable PWM period interrupr request" has no effect on the generated code. The last argument of the CTIMER_SetupPwmPeriod function is always set to false.

MCUXpressoIDE_11.4.1, MacOS.

Regards,
Daniel

0 Kudos
10 Replies

6,905 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

 

Hello,

Which version of IDE and SDK do you used?

I use MCUXpresso IDEv11.4 and SDK 2.10 test, generate code as below:

 

static void CTIMER3_init(void) {
/* CTIMER3 peripheral initialization */
CTIMER_Init(CTIMER3_PERIPHERAL, &CTIMER3_config);
/* Enable interrupt of PWM channel 3 that determinates the PWM period */
CTIMER_EnableInterrupts(CTIMER3_PERIPHERAL, kCTIMER_Match3InterruptEnable);
}

 

BR

Alice

0 Kudos

6,593 Views
danielkrol
Contributor III

Hello Alice,

 

Problem concerns "PWM period interrupt" not "duty PWM interrupt" as in your code!

Screen in the attachment.

 

Best regards,

Daniel

0 Kudos

6,880 Views
danielkrol
Contributor III

Hello Alice,

 

MCUXpressoIDE 11.4.1 - MacOS version

SDK 2.10.1

 

I am enclosing a simple example. In the generated file peripherals.c (line 128), the CTIMER_SetupPwmPeriod function has the last argument set to false.

 

Another BUG: For Timer in Capture mode it is not possible to change the "mode" field (screen in the attachment) in the structure:

const ctimer_config_t CTIMER2_config = {

.mode = kCTIMER_TimerMode,

.input = kCTIMER_Capture_0,

.prescale = 0 };

 

Regards,

Daniel

0 Kudos

6,580 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Daniel,

I have analyzed the attached PWM test application but the generated source code is correct. You must understand that there are two CTIMER channels used for PWM signal generation. One specify the period and the second specify the duty. See the following screenshot that explains which interrupt is enabled and how it is initialized in the source code:

marek_neuzil_0-1637679904076.png

You can see that the channel #3 is used for the PWM period. The interrupt of this channel #3 is enabled by the CTIMER_EnableInterrupts() function call after CTIMER_SetupPWMPeriod() function call.

Best Regards,

Marek Neuzil

0 Kudos

6,576 Views
danielkrol
Contributor III

Hi,

If the last argument of the CTIMER_SetupPwmPeriod function is set to false, interrupts in NVIC will not activate (screenshot in attachment). The code which you showed won't work!

If I add a line (eg in main): "EnableIRQ (CTIMER2_TIMER_IRQN);"
everything works fine!

So, tell me how can I enable (correctly) "PWM period interrupt" from Config Tool? 

edit:

It looks like the CTIMER_EnableInterrupts() function will not call the EnableIRQ() function for NVIC.

 

Best Regards,

Daniel

0 Kudos

6,532 Views
marek_neuzil
NXP Employee
NXP Employee

Hi Daniel,

You are right. When the PWM period interrupt request is enabled only the interrupt vector is not enabled in the NVIC. The CTIMER driver API is not consistent in this case. It can be fixed in the CTIMER component (I will create an issue and I will fix it).

You can either enable the PWM duty interrupt request and in the callback function you must check the status flags to distinguish the channel (the value of the flags parameters contains the value of the CTIMER IR register) or you can enable the interrupt vector in the NVIC by using the NVIC component that is already in your project. See the following screenshots:

marek_neuzil_0-1637736580967.png

marek_neuzil_1-1637736625424.png

Best Regards,

Marek Neuzil

0 Kudos

6,525 Views
danielkrol
Contributor III

Hi Marek,

Thank you for the answer that helped me analyze the problem.
However, both solution - my with the addition of EnableIRQ (CTIMER2_TIMER_IRQN) in the code and your suggestions are not very elegant.

BTW. I noticed the same problem in LPC804 - in this case it is not possible to configure the NVIC block from the Config Tools.

I teach students to program various NXP chips and I want to show the good side of the yours tools (they are really great in my opinion)!

In conclusion, I have a question: Do you plan to fix the CTIMER_EnableInterrupts() function to enable an interrupt in NVIC?

 

Best Regards,

Daniel

0 Kudos

6,501 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Daniel,

I agree the solution I have proposed is just a workaround of the issue. The issue is caused by atypical implementation of the CTIMER_SetupPWMPeriod() function that enable also the interrupt vector in the NVIC (it is done due to interrupt routine in the CTIMER driver that provides callback functions).

I have already fixed the CTIMER component. When the PWM period interrupt request is enabled only the EnableIRQ() function is called to enable the interrupt vector in the NVIC component. This is the only solution I can provide in the CTIMER component now. Let me know whether you need a hot fix for this issue. I can provide a package for update of your local data.

I can report the problem in the CTIMER_EnableInterrupts() function but I am not sure if it is the right solution in this case. If the CTIMER_SetPWMPeriod() function provide configuration both channels (period and duty) both interrupts should be configured in this API functions. So the CTIMER_SetPWMPeriod() function should be updated.

Best Regards,

Marek Neuzil

0 Kudos

6,352 Views
danielkrol
Contributor III

Hello Marek,

Thank you for the answer. At the moment I don't need a "hot fix" because I'm temporarily adding the EnableIRQ line (CTIMERx_TIMER_IRQN), but I will be grateful for fixing this in the next update. Also, keep in mind that the problem is with code generation for other chips as well (I checked LPC804).

I am also waiting for fix an issue with switch CTIMER to Capture mode, that I reported to Alice in this subject.

BTW. Can I ask you to report a small problem (typo) in the generated BULE name instead of BLUE (screenshot in attachment) in BOARD_InitLEDsPins?

Best Regards,
Daniel

 

0 Kudos

6,866 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello danielkrol,

Thanks for your sharing, I have checked on my side, the same issue about "mode", I will report this issue 

to development team. Sorry for the inconvenient to you.

 

BR

Alice

0 Kudos