This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Somebody could tell me, what is the average context switching time on hercules tms570LS20216?
I could measure about 7usec @ 140MHz between the end of a task and the beginning of the next task. If I'am right its about 1000 cycles. The FreeRTOS FAQ (http://www.freertos.org/FAQMem.html#ContextSwitchTime) says that the switching time is 86 cycle in the case of cortex M port. I know that the value depends on the architecture, compiler optimisation etc.. but it is quite big difference.
Thank You Szilard
Szilard,
You can measure this easily by reading the PMU cycle count register between the two points that you want to capture & logging to memory.
If you do not have the code compiled with optimization and instead have debug on - you will get very easy to debug code -- but with poor execution times. So also check your build options. You might just make sure you build the 'Release' profile for your measurement.
Don't try to measure with a GIO pin because there is a lot of latency to read/write a GIO (maybe 22-25 cycles) so if you do that it will throw your measurement off. I believe reading the cycle count in the PMU is just 6 cycles.
Hi, I'm not able to use the PMU with Freertos on the Hercules dev. board. It works if I use it in main before I start a FreeRTOS thread. But after I've started a thread, the MCU stops in an interruptr trap I believe:
undefEntry b undefEntry
It instantly jumps to that trap when this instruction is run:
_pmuGetCycleCount_ mrc p15, #0, r0, c9, c13, #0
Why is this happening?
How to solve this?
Hello Anthony,
This is what I get when stepping
Before MRC
CPSR 0x60000310
EE190F1D mrc p15, #0, r0, c9, c13, #0
After MRC / In trap
CPSR 0x6000039B
EAFFFFFE b undefEntry
From the description of CPSR I understand that CPU is using not (not added in edit) Thumb2 in User mode before instruction. I don't know how to find out if my MRC instruction is Thumb. It's in Undef mode in the trap.
In main
CPSR 0x6000039F
Which means System mode
Haven't tried xTaskCreateRestricted yet
This did the trick. Now I can read the cyclecounter in user mode. Thanks for the help!
Added four lines in top of this function.
_pmuInit_
; User mode access to performance monitor and validation registers mov r0, #1 mcr p15, #0, r0, c9, c14, #0 ; Write USEREN Register mov r0, #0x8000000f mcr p15, #0, r0, c9, c14, #2 ; Something to do with interrupts