- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Due to lack of UDB resources, I am trying to use the fixed function implementation of PWM.
I am using 16bit resolution.
Period of 1ms (9) and CMP value of 5.
The CMP type is "less" and the dead band is disabled.
The kill value is 1 and the reset value is 0.
As mentioned in the datasheet, the PWM output is 0.
I connected scope to the TC output and I saw duty cycle of 100us and period of 1ms (attached pic).
If I am changing the period value in the Top Design, The period in the output is changed but I can't control the duty cycle.
I also tried to use the function PWM_setValue() but it didn't change anything.
What am I doing wrong? How can I control the duty cycle of FF PWM?
(If I am using UDB implementation it works).
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried with CY8CKIT-059.
With the attached sample, when you start the program
program name and a prompt "> " will be shown in a serial terminal program.
Since the default duty (or compare) is set to 127, about 50% duty wave is generated.
When I entered "30" at the prompt
And whan I entered 200 at the prompt
Schematic
Pins
main.c
#include "project.h"
#include "stdio.h"
#include "tty_utils.h"
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
tty_init() ;
splash("Fixed PWM duty test") ;
PWM_Start() ;
}
void set_pwm_duty(int duty)
{
PWM_Stop() ;
PWM_WriteCompare(duty) ;
PWM_Start() ;
}
int main(void)
{
int duty = 0 ;
init_hardware() ;
prompt("> ") ;
for(;;)
{
if (get_line()) {
sscanf(str, "%d", &duty) ;
set_pwm_duty(duty) ;
prompt("> ") ;
}
}
}
/* [] END OF FILE */
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried with CY8CKIT-059.
With the attached sample, when you start the program
program name and a prompt "> " will be shown in a serial terminal program.
Since the default duty (or compare) is set to 127, about 50% duty wave is generated.
When I entered "30" at the prompt
And whan I entered 200 at the prompt
Schematic
Pins
main.c
#include "project.h"
#include "stdio.h"
#include "tty_utils.h"
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
tty_init() ;
splash("Fixed PWM duty test") ;
PWM_Start() ;
}
void set_pwm_duty(int duty)
{
PWM_Stop() ;
PWM_WriteCompare(duty) ;
PWM_Start() ;
}
int main(void)
{
int duty = 0 ;
init_hardware() ;
prompt("> ") ;
for(;;)
{
if (get_line()) {
sscanf(str, "%d", &duty) ;
set_pwm_duty(duty) ;
prompt("> ") ;
}
}
}
/* [] END OF FILE */
moto