Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
KevinSon
Level 3
Level 3
50 sign-ins 10 replies posted 5 questions asked

Hello.
I have  one question.

Used Evkit   CYTVII-B-E-1M-SK. 

Set P6.3 to Pwm Pulse Output. 
I want to interrupt and enter to Pwm_out_isr_handler() by PWM signal output. 

When I excuted attached FW(main_cm4.zip),
PWM (P6.3) is output at 1280us period like below  yellow wave in oscilloscope picture. 

At this time, when I applied GPIO Flag (P11.1) to Pwm_out_isr_handler(),
it was interrupted every 1.54u/2 like below  green wave in oscilloscope picture. 

How can I interrupt by PWM (P6.3) signal output (every 1280us)?

 

Green Color : Toggle_FLAG1(P11.1) 
Yellow Color: PWM Output (P6.3) 

KevinSon_0-1679028304039.png

KevinSon_1-1679028315008.png

 

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
JJack
Level 5
Level 5
Associated Partner - Distributor Rutronik
5 questions asked 25 likes received 100 sign-ins

Hi KevinSon,

your interrupt service routine is missing the part where you reset the interrupt request bit of the peripheral (here TCPWM). If you do not reset the bit then the ISR will be called immediately again after returning from it.

Please try something like in this example when CaptureCompare0 triggered the jump into the ISR:

void Pwm_out_isr_handler(void)
{
   if(Cy_Tcpwm_Counter_GetCC0_IntrMasked(TCPWMx_GRPx_CNTx_PWM))
  {
  // CCO capture
  Cy_Tcpwm_Counter_ClearCC0_Intr(TCPWMx_GRPx_CNTx_PWM); // Clear Interrupt Flag
  Toggle_FLAG1();
}

else

{
  // Unexpected interrupt
  printf("Wrong Interrupt\n\r");
  CY_ASSERT(false);
  }
}

For explanation maybe a look into the attached diagram helps as well.

BR

JJack

View solution in original post

4 Replies
abhikul
Moderator
Moderator
Moderator
50 sign-ins 10 solutions authored 25 replies posted

Hello @KevinSon 

  • Could you please clarify what exactly you mean by the statement "  when I applied GPIO Flag (P11.1) to Pwm_out_isr_handler()" and also can you elaborate it in detail?

Thanks & Regards

Abhishek Kulkarni

0 Likes

For check if Interrupt is caught when Pwm signal is high,
I added debugging  toggle GPIO port (Toggle_FLAG1())  in Pwm_out_isr_handler() function.

Please see below function. 

/**
*****************************************************************************
** PWM Interrupt Handler
** \return none
*****************************************************************************/
void Pwm_out_isr_handler(void)
{
Toggle_FLAG1();

NVIC_ClearPendingIRQ(CPUIntIdx3_IRQn);
}

 

 

0 Likes
lock attach
Attachments are accessible only for community members.
JJack
Level 5
Level 5
Associated Partner - Distributor Rutronik
5 questions asked 25 likes received 100 sign-ins

Hi KevinSon,

your interrupt service routine is missing the part where you reset the interrupt request bit of the peripheral (here TCPWM). If you do not reset the bit then the ISR will be called immediately again after returning from it.

Please try something like in this example when CaptureCompare0 triggered the jump into the ISR:

void Pwm_out_isr_handler(void)
{
   if(Cy_Tcpwm_Counter_GetCC0_IntrMasked(TCPWMx_GRPx_CNTx_PWM))
  {
  // CCO capture
  Cy_Tcpwm_Counter_ClearCC0_Intr(TCPWMx_GRPx_CNTx_PWM); // Clear Interrupt Flag
  Toggle_FLAG1();
}

else

{
  // Unexpected interrupt
  printf("Wrong Interrupt\n\r");
  CY_ASSERT(false);
  }
}

For explanation maybe a look into the attached diagram helps as well.

BR

JJack

KevinSon
Level 3
Level 3
50 sign-ins 10 replies posted 5 questions asked

Dear JJack 

Thank you for your advice. 

It works well. 

 

0 Likes