Jun 09, 2015
06:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 09, 2015
06:42 PM
I am using XMC4500 platform and using a 5 us timer I am not getting good/precise timing. Wondering if somehow I can have access to the CCU8 using native commands? Does anybody try to use that timer to check delta times on interrupt routines?
thanks
thanks
- Tags:
- IFX
15 Replies
Jun 10, 2015
12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
12:54 AM
Hi,
Are you using the system timer tick? This should be quite precise to check delta time base on the number of clock cycles.
Best Regards
Travis
Are you using the system timer tick? This should be quite precise to check delta time base on the number of clock cycles.
Best Regards
Travis
Jun 10, 2015
03:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
03:02 AM
Travis
On my current setup a 5 us is not working for me. Measuring a 20 Ms pwm is not always giving me accurate readings.
Changing to 1 us. Make my software unstable.
Can u tell me how to use the cc4u slice?
On my current setup a 5 us is not working for me. Measuring a 20 Ms pwm is not always giving me accurate readings.
Changing to 1 us. Make my software unstable.
Can u tell me how to use the cc4u slice?
Jun 10, 2015
03:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
03:16 AM
I would like to have 500 ns resolution. Any suggestions how to achieve that?
Jun 10, 2015
04:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
04:03 AM
Travis
Can you provide a way to read the system timer tick?
Can you provide a way to read the system timer tick?
Jun 10, 2015
01:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
01:34 PM
Travis
Based on other threads. I used the following to setup a CC4 slice:
CCU40->GCTRL = (uint32_t)0;
// Set the prescaler value: clock is divided by 2^n, with n=0..15
CCU40_CC40->PSC = 0x0004; // divide 32MHz by 2^15 = 32768 --> 976.6Hz
// Set the period of the timer: 2x per second
CCU40_CC40->PRS = (977 >> 1)-1;
// Enable the synchronized transfer of the period value into the active register
CCU40->GCSS |= CCU4_GCSS_S0SE_Msk;
// Set which interrupt line the timer interrupt is directed toward
WR_REG(CCU40_CC40->SRS, CCU4_CC4_SRS_POSR_Msk, CCU4_CC4_SRS_POSR_Pos, (uint32_t)0x00); // Service Request 0
// Enable interrupt generation on period match
SET_BIT(CCU40_CC40->INTE, CCU4_CC4_INTE_PME_Pos);
/* Enables the timer */
SET_BIT(CCU40->GIDLC, CCU4_GIDLC_CS0I_Pos);
/* Start the timer */
SET_BIT(CCU40_CC40->TCSET, CCU4_CC4_TCSET_TRBS_Pos);
CCU40_CC40->TCSET =0x01;
//CC40TCSET |= 0x00000001; //Start Timer CC40 directly by setting the TRBS bit = 1
// configure and enable interrupt for CCU40 SR0
NVIC_SetPriority(CCU40_0_IRQn, 0xC0); //This CMSIS function configures node 1 to priority level 0 (highes Priority)
NVIC_ClearPendingIRQ(CCU40_0_IRQn); //This function clears node 1 pending status
NVIC_EnableIRQ(CCU40_0_IRQn); //This function enables node 1 for interrupt request generation
and also the IRQ by:
void CCU40_0_IRQHandler() {
IO004_TogglePin(IO004_Handle6);
}
Can you provide some advice on how to debug this issue or setup the timer correctly? thanks
Based on other threads. I used the following to setup a CC4 slice:
CCU40->GCTRL = (uint32_t)0;
// Set the prescaler value: clock is divided by 2^n, with n=0..15
CCU40_CC40->PSC = 0x0004; // divide 32MHz by 2^15 = 32768 --> 976.6Hz
// Set the period of the timer: 2x per second
CCU40_CC40->PRS = (977 >> 1)-1;
// Enable the synchronized transfer of the period value into the active register
CCU40->GCSS |= CCU4_GCSS_S0SE_Msk;
// Set which interrupt line the timer interrupt is directed toward
WR_REG(CCU40_CC40->SRS, CCU4_CC4_SRS_POSR_Msk, CCU4_CC4_SRS_POSR_Pos, (uint32_t)0x00); // Service Request 0
// Enable interrupt generation on period match
SET_BIT(CCU40_CC40->INTE, CCU4_CC4_INTE_PME_Pos);
/* Enables the timer */
SET_BIT(CCU40->GIDLC, CCU4_GIDLC_CS0I_Pos);
/* Start the timer */
SET_BIT(CCU40_CC40->TCSET, CCU4_CC4_TCSET_TRBS_Pos);
CCU40_CC40->TCSET =0x01;
//CC40TCSET |= 0x00000001; //Start Timer CC40 directly by setting the TRBS bit = 1
// configure and enable interrupt for CCU40 SR0
NVIC_SetPriority(CCU40_0_IRQn, 0xC0); //This CMSIS function configures node 1 to priority level 0 (highes Priority)
NVIC_ClearPendingIRQ(CCU40_0_IRQn); //This function clears node 1 pending status
NVIC_EnableIRQ(CCU40_0_IRQn); //This function enables node 1 for interrupt request generation
and also the IRQ by:
void CCU40_0_IRQHandler() {
IO004_TogglePin(IO004_Handle6);
}
Can you provide some advice on how to debug this issue or setup the timer correctly? thanks
Jun 10, 2015
09:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
09:53 PM
Hi,
you can do something like below...
uint32_t Systick_Value[2],Delta;
Systick_Value[0] = SYST_CVR; //Start of measurement, log the first systick counter
Systick_Value[1] = SYST_CVR; //End of measurement, log the second systick counter
Delta = Systick_Value[1] - Systick_Value[0];
you can do something like below...
uint32_t Systick_Value[2],Delta;
Systick_Value[0] = SYST_CVR; //Start of measurement, log the first systick counter
Systick_Value[1] = SYST_CVR; //End of measurement, log the second systick counter
Delta = Systick_Value[1] - Systick_Value[0];
Jun 10, 2015
10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
10:29 PM
Travis
What do I need to include to get access to SYST_CVR. Currently I am getting an error about undeclared variable.
I am planning to read the syst_tick in an ISR.
What do I need to include to get access to SYST_CVR. Currently I am getting an error about undeclared variable.
I am planning to read the syst_tick in an ISR.
Not applicable
Jun 10, 2015
11:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 10, 2015
11:18 PM
Hi Travis, jptalledo
If you want use systick, you must use this command - this configures timer
Next, you must create handler:
Now, you can read value from systick -> systick[0] = SysTick->VAL <- actual value systick
Best Regards,
Blackom
If you want use systick, you must use this command - this configures timer
SysTick_Config(SystemCoreClock/1000); // tick as 1ms
Next, you must create handler:
void SysTick_Handler(void) {
if you don`t create handle you can have problem with dummy_handler
}
Now, you can read value from systick -> systick[0] = SysTick->VAL <- actual value systick
Best Regards,
Blackom
Jun 11, 2015
02:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 11, 2015
02:17 AM
jptalledo wrote:
Travis
What do I need to include to get access to SYST_CVR. Currently I am getting an error about undeclared variable.
I am planning to read the syst_tick in an ISR.
Hi,
The code mentioned is not a direct plug n play but to give you an ideal how you can go about doing it. To some extend you had to adapt the code to your software with knowledge of C programming.
Jun 11, 2015
02:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 11, 2015
02:19 AM
Hi jptalledo,
Pls take the advise from Blackom.
Pls take the advise from Blackom.
Jun 11, 2015
05:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 11, 2015
05:59 AM
Thanks Travis. My concern is that my Dave's Systm002 block is running at 5 us. I would like to use 1 us or better resolution without changing the system tick timer.
any ideas? Can u provide an example using the CCU4 unit instead?
any ideas? Can u provide an example using the CCU4 unit instead?
Jun 14, 2015
06:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 14, 2015
06:41 AM
Travis/Blackhom
I have the systimer configure to 5 us to control other modules. My concern at this point is that timer can't be used for my other needs. I would like to setup another timer with a 0.1 or 0.5 us resolution. CCU4 modules fits the needs but the code I tried seems to do not work. Any advise or help how to setup that timer?
I have the systimer configure to 5 us to control other modules. My concern at this point is that timer can't be used for my other needs. I would like to setup another timer with a 0.1 or 0.5 us resolution. CCU4 modules fits the needs but the code I tried seems to do not work. Any advise or help how to setup that timer?
Not applicable
Jun 17, 2015
03:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 17, 2015
03:36 AM
Hi jptalledo,
This is my code to run CCU4:
If you need 0.1 or 0.5 us resolution you must set prescaler on 0x03. you take 0.06us resolution(120Mhz/8=15Mhz).
Best regards,
Blackom
This is my code to run CCU4:
SCU_RESET->PRSET0 = SCU_RESET_PRSET0_CCU40RS_Msk; // reset CCU4
SCU_RESET->PRCLR0 = SCU_RESET_PRCLR0_CCU40RS_Msk; // end reset
SCU_CLK->CLKSET = SCU_CLK_CLKSET_CCUCEN_Msk; // connect 120Mhz clock to fccu
CCU40->GIDLS = CCU4_GIDLS_SS2I_Msk; // disconnect slice timer CC42 from CCU40
CCU40_CC42->PSC |= 0x0B<CCU40_CC42->TC = CCU4_CC4_TC_CLST_Msk; // set write shadow register to timer whan timer overflow
SCU_GENERAL->CCUCON = SCU_GENERAL_CCUCON_GSC40_Msk; // connect fccu clock to CCU40
CCU40_CC42->INTE = CCU4_CC4_INTE_PME_Msk; //set period match
CCU40->GIDLC = CCU4_GIDLC_SPRB_Msk; //turn on prescaler
CCU40->GIDLC = CCU4_GIDLC_CS2I_Msk; //set idle state timer4_2
CCU40_CC42->TCSET = CCU4_CC4_TCSET_TRBS_Msk; //turn on timer
CCU40_CC42->PRS=293;// set shadow register PR
CCU40->GCSS = CCU4_GCSS_S2SE_Msk; //this command copy value from shadow PR to timer
NVIC_SetPriority(CCU40_0_IRQn, 54); // set priority of IRQ timer
NVIC_EnableIRQ(CCU40_0_IRQn); //turn on IRQ timer
If you need 0.1 or 0.5 us resolution you must set prescaler on 0x03. you take 0.06us resolution(120Mhz/8=15Mhz).
Best regards,
Blackom
Jun 18, 2015
06:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 18, 2015
06:37 AM
Blackhom
Thanks for the source code. I was able to get some interrupts and verifying by toggling a PIN (P1.1) on the Relax Kit. Unfortunately the lowest period I can get is 866 ns.
I changed the PSC to 3 and the PRS to 1,2,3 with the same results. Wondering if the prescaler is doing the correct thing.
Thanks for the source code. I was able to get some interrupts and verifying by toggling a PIN (P1.1) on the Relax Kit. Unfortunately the lowest period I can get is 866 ns.
I changed the PSC to 3 and the PRS to 1,2,3 with the same results. Wondering if the prescaler is doing the correct thing.
Not applicable
Jun 19, 2015
04:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 19, 2015
04:12 AM
Hi,
Yes it maybe true,because you can`t fast toggle pin in software mode. You can generate PWM and it will be more faster.
Best regards,
Blackom
Yes it maybe true,because you can`t fast toggle pin in software mode. You can generate PWM and it will be more faster.
Best regards,
Blackom