- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello sir ,
i have to generate a clock out pulse on fx3 pin using pwm of frequency 24 MHZ with 50% duty cycle for camera module ,also i have merged complexgpio example firmware with uvc .my question is in that complexgpio example they have set period as (201600 - 1) and threshold as (50400 - 1). unable to understand how these values are taken.please help.
Thanks
Manisha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Manisha,
The gpioConfig.period and gpioConfig.threshold parameters define the clock period and the PWM threshold value in terms of the timer ticks. In the case of GpioComplexApp example, these parameters are computed for a SYS_CLK frequency of 403.2MHz. Also, the complex GPIO clock is configured to run from the GPIO fast clock which is set to SYS_CLK/2. So, the value (20160-1) clock ticks would account for 100us and (5040-1) clock ticks would account for 25us. Below are the code statements that are responsible to arrive at this value and the calculation
gpioClock.clkSrc = CY_U3P_SYS_CLK; // GPIO clock is derived from the SYS_CLK
gpioClock.fastClkDiv = 2; // GPIO fast clock is configured for SYS_CLK/2
gpioConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ; // Use the GPIO fast clock for generating the PWM
gpioConfig.period = CY_FX_PWM_PERIOD; // Set the period to 20160 timer ticks
gpioConfig.threshold = CY_FX_PWM_25P_THRESHOLD; // Set the threshold such that the duty cycle is 25%
Calculations:
SYS_CLK frequency = 403.2MHz
GPIO fast clock frequency = (SYS_CLK frequency)/2 = 201.6MHz
One clock period = 1/(GPIO fast clock frequency) = 1/201.6 us
PWM waveform period = (20160) * One clock period = 100 us
PWM threshold = (5040) * One clock period = 25us
Please let me know if you need further clarification.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Manisha,
The gpioConfig.period and gpioConfig.threshold parameters define the clock period and the PWM threshold value in terms of the timer ticks. In the case of GpioComplexApp example, these parameters are computed for a SYS_CLK frequency of 403.2MHz. Also, the complex GPIO clock is configured to run from the GPIO fast clock which is set to SYS_CLK/2. So, the value (20160-1) clock ticks would account for 100us and (5040-1) clock ticks would account for 25us. Below are the code statements that are responsible to arrive at this value and the calculation
gpioClock.clkSrc = CY_U3P_SYS_CLK; // GPIO clock is derived from the SYS_CLK
gpioClock.fastClkDiv = 2; // GPIO fast clock is configured for SYS_CLK/2
gpioConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ; // Use the GPIO fast clock for generating the PWM
gpioConfig.period = CY_FX_PWM_PERIOD; // Set the period to 20160 timer ticks
gpioConfig.threshold = CY_FX_PWM_25P_THRESHOLD; // Set the threshold such that the duty cycle is 25%
Calculations:
SYS_CLK frequency = 403.2MHz
GPIO fast clock frequency = (SYS_CLK frequency)/2 = 201.6MHz
One clock period = 1/(GPIO fast clock frequency) = 1/201.6 us
PWM waveform period = (20160) * One clock period = 100 us
PWM threshold = (5040) * One clock period = 25us
Please let me know if you need further clarification.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks sir for your solution, but when I am setting value for system clock
384mhz period (192 -1) threshold for 50 %duty cycle (9600 -1) for 1mhz
frequency , getting 500khz frequency on oscilloscope . Can you please tell
what exactly the value for generating frequency in MHz .I want approx 10
MHz frequency for camera module.
Thanks
Manisha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Manisha,
Please use the below configuration.
gpioClock.clkSrc = CY_U3P_SYS_CLK; // GPIO clock is derived from the SYS_CLK (403.2 MHz)
gpioClock.fastClkDiv = 2; // GPIO fast clock is configured for SYS_CLK/2 (201.6 MHz)
gpioConfig.timerMode = CY_U3P_GPIO_TIMER_HIGH_FREQ; // Use the GPIO fast clock for generating the PWM
gpioConfig.period = 20; // Set the period to 20 timer ticks (20*1/201.6 us) ~= 0.1us -> 10 MHz
gpioConfig.threshold = 10; // Set the threshold such that the duty cycle is 50%
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello sir ,
Thanks for the solution. I have used system frequency as
384mhz and done calculations accordingly.But another problem I faced is in
my uvc code I have merged complexgpio pwm code .but only pwm code is
working and I am getting 10mhz frequency on gpio 50.can you please suggest
solution for it .
Thanks and regards
Manisha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Manisha,
I am not clear with your problem. Do you mean to say that when the complexgpio pwm code is integrated with the UVC application code, there is a problem. If yes, please mention the issue.
EDIT: Since this query is different from the one the thread was created for, it has been branched to a new thread.
Best regards,
Srinath S