- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
PWM config
Timer config
Pins
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
PWM config
Timer config
Pins
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