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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,462 次查看
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 解答
1,450 次查看
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 回复数
1,437 次查看
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 项奖励
回复
1,433 次查看
frank_m
Senior Contributor III
0 项奖励
回复
1,451 次查看
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 项奖励
回复