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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
761件の閲覧回数
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 件の賞賛
1 解決策
749件の閲覧回数
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 件の賞賛
3 返答(返信)
736件の閲覧回数
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 件の賞賛
732件の閲覧回数
frank_m
Senior Contributor III
0 件の賞賛
750件の閲覧回数
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 件の賞賛