Dec 04, 2019
07:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 04, 2019
07:01 PM
Hello
I use aurix development studio to learn AURIX tc297.
when I used the demo "CCU6_PWM_Generation" to generate the PWMs with a lower frequency, for example 5000Hz (modify the marco "#define PWM_FREQUENCY 5000"), I cannot get a valid pwm signal.
I check the code some time, and not find any reason, can any one can help me?
Thank you.
I use aurix development studio to learn AURIX tc297.
when I used the demo "CCU6_PWM_Generation" to generate the PWMs with a lower frequency, for example 5000Hz (modify the marco "#define PWM_FREQUENCY 5000"), I cannot get a valid pwm signal.
I check the code some time, and not find any reason, can any one can help me?
Thank you.
2 Replies
Dec 05, 2019
08:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 05, 2019
08:27 AM
Hello,
When you modify the macro for the frequency of the PWM signals, all the calculations made for the compare values are not necessarily correct anymore because the CCU6_BASE_FREQUENCY is divided internally in order to be able to generate the needed frequency for the PWM signals.
You can overcome this problem by replacing the instructions where the compare values are set to obtain the desired duty cycles during initialization of the CCU6 (inside initCCU6())
with the following:
where DUTY_CYCLE_CH1, DUTY_CYCLE_CH2, DUTY_CYCLE_CH3 are the duty cycles of each signal (which can be a value from 0 to 1) and can be defined as following:
hope it helps,
teoBits
When you modify the macro for the frequency of the PWM signals, all the calculations made for the compare values are not necessarily correct anymore because the CCU6_BASE_FREQUENCY is divided internally in order to be able to generate the needed frequency for the PWM signals.
You can overcome this problem by replacing the instructions where the compare values are set to obtain the desired duty cycles during initialization of the CCU6 (inside initCCU6())
Ifx_TimerValue cmpValues[NUMBER_OF_CHANNELS];
cmpValues[0] = CHANNEL1_COMPARE_VALUE; /* Set the compare value for channel 1 */
cmpValues[1] = CHANNEL2_COMPARE_VALUE; /* Set the compare value for channel 2 */
cmpValues[2] = CHANNEL3_COMPARE_VALUE; /* Set the compare value for channel 3 */
with the following:
Ifx_TimerValue cmpValues[NUMBER_OF_CHANNELS];
cmpValues[0] = g_timer.base.period * (1 - DUTY_CYCLE_CH1); /* Set the compare value for channel 1 */
cmpValues[1] = g_timer.base.period * (1 - DUTY_CYCLE_CH2); /* Set the compare value for channel 2 */
cmpValues[2] = g_timer.base.period * (1 - DUTY_CYCLE_CH3); /* Set the compare value for channel 3 */
where DUTY_CYCLE_CH1, DUTY_CYCLE_CH2, DUTY_CYCLE_CH3 are the duty cycles of each signal (which can be a value from 0 to 1) and can be defined as following:
#define DUTY_CYCLE_CH1 0.25
#define DUTY_CYCLE_CH2 0.50
#define DUTY_CYCLE_CH3 0.75
hope it helps,
teoBits
Dec 06, 2019
09:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 06, 2019
09:38 PM
Thank you.