I have initialized the above controller in C++ in Keil 5uV. After the initialization, I want to jump to or enter a timing critical assembly language algorithm under the int main(void) statement. What is the preferred method to accomplish this?
MJ
For Keil MDK, the embedded assembler feature in ARM C compiler is quite easy to use: ARM Information Center
For timing critical code, you might want to disable interrupts before execute the algorithm, and reenable interrupts afterwards. To do this, you can set PRIMASK (a special register) to 1 to disable all interrupts, and clear it afterwards. Assumed that you are using device driver header files with CMSIS, and only one place in your software need to do this interrupt masking, you can use:
__disable_irq(); // Set PRIMASK
foo(); // timing critical function
__enable_irq(); // Clear PRIMASK
More information can be found here: https://www.keil.com/pack/doc/CMSIS/Core/html/group___core___register__gr.html
https://www.keil.com/pack/doc/CMSIS/Core/html/group___core___register__gr.html
regards,
Joseph
View all questions in Cortex-M / M-Profile forum