Not applicable
Aug 21, 2014
06:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 21, 2014
06:13 AM
Hi All,
I am wondering if there is an error in the "PWMSP002_SetPwmFreqAndDutyCycle" function when it calculates the timer value if concatenation is required. My PWMSP002 is configured for Edge Aligned Counting Mode and Symetric Compare Mode.
The function calculates the count to load into the CCU80_CC80.PRS and CCU80_CC81.PRS shadow registers for the required PWM period.
The calculation is actually performed by the "CCU8PWMLIB_lSetPwmFreqTimerConcat" function in the CCU8PWMLIB.c library (code snippet visible in screenshhots).
In the fist example below the MSB and LSB period counts are correct, the second example with a count greater than 65535 the counts seem wrong...
Am I missing something ?
Any help would be greatly appreciated.
Best regards
Aaron
I am wondering if there is an error in the "PWMSP002_SetPwmFreqAndDutyCycle" function when it calculates the timer value if concatenation is required. My PWMSP002 is configured for Edge Aligned Counting Mode and Symetric Compare Mode.
The function calculates the count to load into the CCU80_CC80.PRS and CCU80_CC81.PRS shadow registers for the required PWM period.
The calculation is actually performed by the "CCU8PWMLIB_lSetPwmFreqTimerConcat" function in the CCU8PWMLIB.c library (code snippet visible in screenshhots).
In the fist example below the MSB and LSB period counts are correct, the second example with a count greater than 65535 the counts seem wrong...
Example 1 (correct)
PwmTime = 65535
Call to CCU8PWMLIB_lSetPwmFreqTimerConcat
Result
MsbPeriodVal = 0x00
LsbPeriodVal = 0xFFFF
Example 2 (incorrect ?)
PwmTime = 65536
Call to CCU8PWMLIB_lSetPwmFreqTimerConcat
Result
MsbPeriodVal = 0x3
LsbPeriodVal = 0x3FFF
Am I missing something ?
Any help would be greatly appreciated.
Best regards
Aaron
8 Replies
Not applicable
Aug 21, 2014
08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 21, 2014
08:19 AM
I have also noticed a possible problem with the calculation of the duty cycle count which is done within the "CCU8PWMLIB_SetDutyEdgeAlignSymmetricTimerConcat" function when timers are concatenated to achieve the desired period time.
For example...
If the Period count in CCU80_CC80.PRS and CCU80_CC81.PRS is 65535 and a DutyCycle of 99.5 is requested the result is 327 (0.5 % of 65535 which is correct)
If the Period count in CCU80_CC80.PRS and CCU80_CC81.PRS is 65536 and a DutyCycle of 99.5 is requested the result is 655 (0.5 % of 65536 should be 327 still ?)
Best regards
Aaron
For example...
If the Period count in CCU80_CC80.PRS and CCU80_CC81.PRS is 65535 and a DutyCycle of 99.5 is requested the result is 327 (0.5 % of 65535 which is correct)
If the Period count in CCU80_CC80.PRS and CCU80_CC81.PRS is 65536 and a DutyCycle of 99.5 is requested the result is 655 (0.5 % of 65536 should be 327 still ?)
Best regards
Aaron
Not applicable
Aug 25, 2014
11:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 25, 2014
11:51 PM
Hi Aaron,
Just to confirm:
1) Was the timer concatenation not set as per initial PWM frequency (eg. 1500Hz by default) in PWMSP002 GUI?
2) Did you try to call PWMSP002_SetPwmFreqAndDutyCycle() API to change the PWM frequency during run time which requires timer concatenation (eg. 500Hz)?
If the answers are "Yes" for both questions, then I regret to tell you that it will not work always due to the limitation of this App (eTicket 841909820).
Best regards,
Sophia
Just to confirm:
1) Was the timer concatenation not set as per initial PWM frequency (eg. 1500Hz by default) in PWMSP002 GUI?
2) Did you try to call PWMSP002_SetPwmFreqAndDutyCycle() API to change the PWM frequency during run time which requires timer concatenation (eg. 500Hz)?
If the answers are "Yes" for both questions, then I regret to tell you that it will not work always due to the limitation of this App (eTicket 841909820).
Best regards,
Sophia
Not applicable
Aug 26, 2014
12:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 26, 2014
12:52 AM
Hi Sophia,
Thanks for your reply.
My PWMSP002 App is configured for 2Hz with concatenation before code generation and I am setting a frequency of 10Hz at run time.
The "CCU8PWMLIB_lSetPwmFreqTimerConcat" library function code to calculate the high counter value looks a little strange...
I replaced this code with my own and concatenation appears to work correctly...
Is there something else I am doing wrong ?
Best regards
Aaron
Thanks for your reply.
My PWMSP002 App is configured for 2Hz with concatenation before code generation and I am setting a frequency of 10Hz at run time.
The "CCU8PWMLIB_lSetPwmFreqTimerConcat" library function code to calculate the high counter value looks a little strange...
if(PwmTime > CCU8PWMLIB_MAX_VALUE)
{
do
{
PeriodVal = PeriodVal >> 1U;
Count++;
}while(PeriodVal >= CCU8PWMLIB_MAX_VALUE);
MsbPeriodVal = ((uint32_t)1 << Count) -1U;
LsbPeriodVal = PeriodVal;
}
else
{
LsbPeriodVal = PwmTime;
MsbPeriodVal = 0U;
}
I replaced this code with my own and concatenation appears to work correctly...
if(PwmTime > CCU8PWMLIB_MAX_VALUE)
{
MsbPeriodVal = PwmTime >> 16;
LsbPeriodVal = PwmTime & 0x0000FFFF;
}
else
{
LsbPeriodVal = PwmTime;
MsbPeriodVal = 0U;
}
Is there something else I am doing wrong ?
Best regards
Aaron
Not applicable
Aug 27, 2014
02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 27, 2014
02:48 AM
Hi Aaron,
It has been forwarded further. Will update you once get reply.
Best regards,
Sophia
It has been forwarded further. Will update you once get reply.
Best regards,
Sophia
Attachments are accessible only for community members.
Not applicable
Sep 02, 2014
01:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2014
01:04 AM
Hi Aaron,
I have no problem if using PWMSP002_SetPwmFreqAndDutyCycle() API to change the PWM frequency during run time unless using PWMSP002_SetPwmFreq() API only (eTicket 171922682).
Attached example for your reference.
Best regards,
Sophia
I have no problem if using PWMSP002_SetPwmFreqAndDutyCycle() API to change the PWM frequency during run time unless using PWMSP002_SetPwmFreq() API only (eTicket 171922682).
Attached example for your reference.
Best regards,
Sophia
Not applicable
Sep 03, 2014
02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 03, 2014
02:36 AM
Hi Sophia,
Thank you for your help. My mistake, I think I've worked out how the concatenated timers work !
Please can you confirm....
High Slice value____Low Slice value____Timer operation
0x0000____________ 0xFFFF___________Counts up to 0xFFFF
0x0001____________ 0x8000____________Counts up to 0x8000 x 2 which is 0x10000 (it does not count up to 0x18000)
Best regards
Aaron
Thank you for your help. My mistake, I think I've worked out how the concatenated timers work !
Please can you confirm....
High Slice value____Low Slice value____Timer operation
0x0000____________ 0xFFFF___________Counts up to 0xFFFF
0x0001____________ 0x8000____________Counts up to 0x8000 x 2 which is 0x10000 (it does not count up to 0x18000)
Best regards
Aaron
Not applicable
Sep 03, 2014
03:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 03, 2014
03:15 AM
Hi Aaron,
During the timer concatenation, whenever lower timer has exceeded the max period value, higher timer will count +1, and then lower timer will restart from zero.
This will go on unless higher timer reached the max period value.
Best regards,
Sophia
During the timer concatenation, whenever lower timer has exceeded the max period value, higher timer will count +1, and then lower timer will restart from zero.
This will go on unless higher timer reached the max period value.
Best regards,
Sophia
Not applicable
Sep 04, 2014
11:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 04, 2014
11:59 PM
Hi All,
It seems the root cause of my problems with the PWMSP002 App were due to the "PWMSP002_SetTimerVal()" function so this post is now resolved.
http://www.infineonforums.com/threads/2198-PWMSP002_SetTimerVal-uses-a-different-method-to-PWMSP002_...
Best regards
Aaron
It seems the root cause of my problems with the PWMSP002 App were due to the "PWMSP002_SetTimerVal()" function so this post is now resolved.
http://www.infineonforums.com/threads/2198-PWMSP002_SetTimerVal-uses-a-different-method-to-PWMSP002_...
Best regards
Aaron