LPC54618 can't set two PWM signals at a time?

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

LPC54618 can't set two PWM signals at a time?

Jump to solution
738 Views
Xiaoyh
Contributor III

        I want to set two PWM singals at a time ? But I the result is error.

       My code :

          SCTIMER_GetDefaultConfig(&sctimerInfo);

            /* Initialize SCTimer module */
           SCTIMER_Init(SCT0, &sctimerInfo);

           /* Configure first PWM with frequency 24kHZ from first output */
           pwmParam.output = DEMO_FIRST_SCTIMER_OUT;
           pwmParam.level = kSCTIMER_HighTrue;
           pwmParam.dutyCyclePercent = 90;
           if (SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 500U,             sctimerClock, &event1) == kStatus_Fail)
          {
              return -1;
           }

         /* Configure second PWM with different duty cycle but same frequency as before */
          pwmParam.output = DEMO_SECOND_SCTIMER_OUT;
          pwmParam.level = kSCTIMER_HighTrue;
          pwmParam.dutyCyclePercent = 90;
          if (SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 1000000U,                sctimerClock, &event2) == kStatus_Fail)
         {
           return -1;
          }

         /* Start the timer */
       SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_L);

      I find that the first PWM singal can't set successful when I set second PWM singal ,but the first PWM singal can work well when I just configure it. What make that happed?

                                                                                                          thank you! 

0 Kudos
1 Solution
726 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello yang1,

For one counter, only can generate one period PWM, when you set "1000000U" in

second PWM configuration, it will coverage the first setting "500u".

You can try to configure the SCT0 as two 16-bit counters.

Alice_Yang_0-1618216730968.png

 

 

BR

Alice

 

View solution in original post

0 Kudos
3 Replies
713 Views
Xiaoyh
Contributor III

Thank you for your reply,I use two 16-bit counters to produce two pwms,but when I try to change their duty,it case a HardFault_Handler.

  MY code:

 i = SCT0->EV[eventCounterH].CTRL & SCT_EV_CTRL_MATCHSEL_MASK;

SCTIMER_StopTimer(SCT0, kSCTIMER_Counter_H);
SCT0->MATCH[i] = (5-1)<<16;
SCT0->MATCHREL[i] = (5-1)<<16;
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_H); 

                                                                                                                thank you!

0 Kudos
709 Views
frank_m
Senior Contributor III
0 Kudos
727 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello yang1,

For one counter, only can generate one period PWM, when you set "1000000U" in

second PWM configuration, it will coverage the first setting "500u".

You can try to configure the SCT0 as two 16-bit counters.

Alice_Yang_0-1618216730968.png

 

 

BR

Alice

 

0 Kudos