May 11, 2020
10:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 11, 2020
10:39 AM
I used the TimerWIthTrigger example for the CCU6 to operate the T12 timer in UpDown mode together with a PWM and the T13 timer in single shot mode to generate a trigger in the middle of the pwm intervall that
is used to start a scan with 1 channel on group 0 of the adc, The EOC of the adc is used to generate an interrupt for cpu0.
Additionally the trigger signal is shown on a pin for test purposes.
So far everything works fine.
The trigger gets active in the middle of the pwm interval and the isr is called to read converted value from adc.
The big problem: the time form start of convertion of the adc (trigger) to start of the isr is nearly 4 µs. This cannot be!!!!
Starting the isr directly with the trigger takes less than 0,2 µs. The conversion time of the adc should be below 1 µs.
What happens in the rest of the time?
Has anyone an explanation?
is used to start a scan with 1 channel on group 0 of the adc, The EOC of the adc is used to generate an interrupt for cpu0.
Additionally the trigger signal is shown on a pin for test purposes.
So far everything works fine.
The trigger gets active in the middle of the pwm interval and the isr is called to read converted value from adc.
The big problem: the time form start of convertion of the adc (trigger) to start of the isr is nearly 4 µs. This cannot be!!!!
Starting the isr directly with the trigger takes less than 0,2 µs. The conversion time of the adc should be below 1 µs.
What happens in the rest of the time?
Has anyone an explanation?
7 Replies
May 11, 2020
12:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 11, 2020
12:37 PM
Is there an OS in the way, or is your breakpoint directly on the vector in BIV?
Are you using the MCAL, or the iLLD? Could your use of CCU6 T13 be interfering with the workaround listed in the errata sheet for ADC_TC.068?
For your application, what are the settings for SPB clock, GLOBCFG.DIVA, GLOBCFG.DIVD, and GxARBCFG.ARBRND?
Are there other higher priority interrupts in your application?
Are there critical sections in your application where interrupts are disabled?
Are you using the MCAL, or the iLLD? Could your use of CCU6 T13 be interfering with the workaround listed in the errata sheet for ADC_TC.068?
For your application, what are the settings for SPB clock, GLOBCFG.DIVA, GLOBCFG.DIVD, and GxARBCFG.ARBRND?
Are there other higher priority interrupts in your application?
Are there critical sections in your application where interrupts are disabled?
May 12, 2020
04:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 12, 2020
04:16 AM
Hi UC_wrangler, thank you very much for your attention.
I have a very small test environment. No OS, isr called direct, no critical sections, not other interrupt.
iLLD is used.
Workarounds mentioned in errata sheet were not used.
GLOBCFG.DIVA = 4
GLOBCFG.DIVD = 0
GxARBCFG.ARBRND = 0
Vadc digitalFrequency = 1e8
Vadc analog Frequency 2e7
Vadc module frequency 1e8
CCU6 frequency 1e8
I have a very small test environment. No OS, isr called direct, no critical sections, not other interrupt.
iLLD is used.
Workarounds mentioned in errata sheet were not used.
GLOBCFG.DIVA = 4
GLOBCFG.DIVD = 0
GxARBCFG.ARBRND = 0
Vadc digitalFrequency = 1e8
Vadc analog Frequency 2e7
Vadc module frequency 1e8
CCU6 frequency 1e8
May 12, 2020
06:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 12, 2020
06:46 AM
Those basics look OK. How about the VADC channel configuration? Can you capture GxCHCTRy, GxICLASS0/1, and GLOBICLASS0/1? Perhaps STCS is too big.
May 12, 2020
10:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 12, 2020
10:59 AM
I show you how I got the required info, to avoid misunderstandings:
MODULE_VADC.G[0].CHCTR[0].U=0
MODULE_VADC.G[0].ICLASS[0].B.STCS=18
MODULE_VADC.GLOBICLASS[0].B.STCS=18
MODULE_VADC.G[0].ICLASS[1].B.STCS=18
MODULE_VADC.GLOBICLASS[1].B.STCS=18
MODULE_VADC.G[0].CHCTR[0].U=0
MODULE_VADC.G[0].ICLASS[0].B.STCS=18
MODULE_VADC.GLOBICLASS[0].B.STCS=18
MODULE_VADC.G[0].ICLASS[1].B.STCS=18
MODULE_VADC.GLOBICLASS[1].B.STCS=18
May 12, 2020
01:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 12, 2020
01:47 PM
Per Table 28-4 on page 3953: STCS=18 gives an effective sample time of 50 / fADCI
Then from 28.6.7 Conversion Timing on page 3967:
tCN = (2 + STC + N + PC) * tADCI + 2 * tVADC
= (2 + 50 + 12 + 2) * 50 ns + 20 ns
= 3300 ns
Could you try something like this to reduce STCS?
That should bring your time down. Whether that sampling time is enough depends on your impedance, etc.
Then from 28.6.7 Conversion Timing on page 3967:
tCN = (2 + STC + N + PC) * tADCI + 2 * tVADC
= (2 + 50 + 12 + 2) * 50 ns + 20 ns
= 3300 ns
Could you try something like this to reduce STCS?
// I'm not entirely sure how the math works in this function but the goal is to get STCS=10
IfxVadc_setGroupSampleTime( vadcg, 0, 12000000.0, 0.000001);
That should bring your time down. Whether that sampling time is enough depends on your impedance, etc.
May 13, 2020
01:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 13, 2020
01:46 AM
Thanks a lot. This works.
There is an error in
IFX_INLINE uint32 IfxVadc_calculateSampleTime(float32 analogFrequency, float32 sampleTime)
{
uint32 ticks;
ticks = (uint32)(sampleTime * analogFrequency) - 2;
if (ticks > 16) // >31 will ignore some allowed values of ticks. 16 corresponds to table 28-4 in the manual
{
ticks = (ticks / 16) + 15;
}
ticks = __minu(ticks, 0xFFu);
return ticks;
}
I set the samplingTime=1e-7 to get an STCS=0. This is lower then your proposed 10. Is there any drawback with the smaller value?
There is an error in
IFX_INLINE uint32 IfxVadc_calculateSampleTime(float32 analogFrequency, float32 sampleTime)
{
uint32 ticks;
ticks = (uint32)(sampleTime * analogFrequency) - 2;
if (ticks > 16) // >31 will ignore some allowed values of ticks. 16 corresponds to table 28-4 in the manual
{
ticks = (ticks / 16) + 15;
}
ticks = __minu(ticks, 0xFFu);
return ticks;
}
I set the samplingTime=1e-7 to get an STCS=0. This is lower then your proposed 10. Is there any drawback with the smaller value?
May 13, 2020
06:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May 13, 2020
06:53 AM
Whether the smaller value will work depends on your analog circuit. See Application Note AP56003 on MyICP for details - in particular, section 5.4.
Sampling too fast will lead to increased error.
Sampling too fast will lead to increased error.