Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Yash_r
New Contributor II

Hello,


I have been trying to configure the TImer component in the PSOC Creator library to implement the functionality mentioned in the PSOC 101: Lesson 9 Timer, but can't seem to properly configure the Timer component properly.

I know the PSOC 4 has a special TCPWM component, which is used in the tutorial. 
Can anyone help me how to bring the same functionality of the Lesson 9 with PSOC 5LP and give some explaination for the same?

Looking forward to get some insight.

Regards,
Yash

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Hi,

I tried with CY8CKIT-059 .

I hope this could be somewhat you wanted...

 

And I found  a few traps 😉

(1) First of all there is no such thing TCPWM, so use Timer and PWM

(2) Timer is "Down only" counter

(3) 10KHz Timer clock may be too fast for those slow people, including me.

      So I changed it to 1KHz.

(4) Similarly I changed the period of PWM to 65535 to make it more forgiving.

 

schematic

001-schematic.JPG

PWM config

003-PWM_Settings.JPG

Timer config

004-Timer_Settings.JPG

Pins

002-Pins.JPG

main.c

#include "project.h"

uint16_t pwm_period = 0xFFFF ;

CY_ISR(Timer_Int_Handler)
{
    int32_t counter ;
    
    counter = 0xFFFF - Timer_ReadCapture() ;

    if ( counter > pwm_period ) {
        counter = pwm_period ;
    }
    
    PWM_WriteCompare(counter) ;
    
    Timer_ReadStatusRegister() ;
    Timer_WriteCounter(0) ;
}

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    PWM_Start() ;
    Timer_Start() ;
    pwm_period = Timer_ReadPeriod() ;
    Timer_Int_StartEx(Timer_Int_Handler) ;

    for(;;)
    {
        /* Place your application code here. */
    }
}

 

moto

View solution in original post

1 Reply
MotooTanaka
Esteemed Contributor

Hi,

I tried with CY8CKIT-059 .

I hope this could be somewhat you wanted...

 

And I found  a few traps 😉

(1) First of all there is no such thing TCPWM, so use Timer and PWM

(2) Timer is "Down only" counter

(3) 10KHz Timer clock may be too fast for those slow people, including me.

      So I changed it to 1KHz.

(4) Similarly I changed the period of PWM to 65535 to make it more forgiving.

 

schematic

001-schematic.JPG

PWM config

003-PWM_Settings.JPG

Timer config

004-Timer_Settings.JPG

Pins

002-Pins.JPG

main.c

#include "project.h"

uint16_t pwm_period = 0xFFFF ;

CY_ISR(Timer_Int_Handler)
{
    int32_t counter ;
    
    counter = 0xFFFF - Timer_ReadCapture() ;

    if ( counter > pwm_period ) {
        counter = pwm_period ;
    }
    
    PWM_WriteCompare(counter) ;
    
    Timer_ReadStatusRegister() ;
    Timer_WriteCounter(0) ;
}

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    PWM_Start() ;
    Timer_Start() ;
    pwm_period = Timer_ReadPeriod() ;
    Timer_Int_StartEx(Timer_Int_Handler) ;

    for(;;)
    {
        /* Place your application code here. */
    }
}

 

moto

View solution in original post