How to perform an Assembly code within a C program in Keil for ARM cortex M
Dr. Carlos Hernandez-Gutierrez.
This sample is to perform an Assembly code within a C program.
The function is for a delay routine, where the R0 loads the value of n parameter of Delay function.
Then R0 is decreased to 0 and Jump to Delay until R0 is 0.
The routine spends three machine cycles. Thus if the clock system is 80MHz the delay obeys to the following formula.
Delay = n * 3 (1/80Mhz)
/* ****************************************************************************/*
__asm void
Delay(unsigned long n)
{
SUBS R0, #1
BNE Delay
BX LR ; //the link register is providing the address to branch to.
}
No hay comentarios.:
Publicar un comentario