Swap PWM period

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.
ArOg_285336
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

I'm trying to do the layout in which the LED will glow with 2 different frequencies.
I am using  function PWM_SetPeriodSwap () but it has no effect.

How to turn PWM perio and period_buf?

0 Likes
3 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You have to check off the swap capability and enter the swap values.

   

 

   

   

 

   

 

   

Note you can do the switch in HW by enabling the switch input and feeding

   

it with a switch signal.

   

 

   

Regards, Dana

0 Likes
ArOg_285336
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

I want to use the API and by  software modify the parameters.

   

 

   

    CyGlobalIntEnable;  /* Uncomment this line to enable global interrupts. */
    for(;;)
    {

        if(counter ==5)
        {
            PWM_SetPeriodSwap(1u);
            PWM_SetCompareSwap(1u);
        }
        
      
    }

   

Why is this simple code does not work?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Two questions -

   

 

   

1) Did you check the properties to allow the swap capability ?

   

 

   

2) Can you set a breakpoint and hit it on the swap instruction ?

   

Eg. are you getting into the if statement test on counter ?

   

 

   

3) Where do you reset counter variable after doing swap, otherwise

   

you will keep repeating the swap commands ?

   

 

   

You also have to have the compare checked.

   

 

   

   

 

   

 

   

 

   

Regards, Dana.

0 Likes