Does the processor frequency change when switching from secure to non secure domain?


I am using a Nuvoton M2351 for my research. I am running into a very weird issue. I am trying to get some portions of FreeRTOS to run inside the secure domain. I am using the EventRecorder API to time sections of the code (EventStartA and EventStopA). The processor is set at 12 MHz core clock and I am building the code without any optimizations enabled. While timing a simple for loop (which increments a value) running 1000 times in the secure domain, I log around 2ms. The exact same loop, when implemented in a non-secure function and called from the secure domain, takes 2.9 ms. This is nearly a 1.5X increase in runtime. Considering the function call overhead across domains is around 20-30 instructions, this is extremely high. Am I doing something wrong to cause this? Does the processor frequency change when switching? I can't make any sense of this behavior. Any help would be appreciated.

Thank you

More questions in this forum