2012-12-18 10:19 PM
I needprecise microseconds delay routine in myapplication ( uses STM32F103RE)
I sawhttps://github.com/leaflabs/libmaple/blob/master/libmaple/include/libmaple/delay.h
for microseconds delay routine. It has the following:static
inline
void
delay_us(uint32 us) {
us *= STM32_DELAY_US_MULT;
/* fudge for function call overhead */
us--;
asm
volatile
(
'' mov r0, %[us] \n\t''
''1: subs r0, #1 \n\t''
'' bhi 1b \n\t''
:
: [us]
''r''
(us)
:
''r0''
);
}
I'm trying to rewrite this routing in IAR EWARM 6.3
I would like to write the same function in IAR EWARM 6.3
I get the following error if I use the same code:
Error[Og006]: Syntax error in inline assembly: ''Error[41]: Bad label''
Anyone who hasexperience in writing code using IAR embedded workbech, suggestions pleas
2012-12-19 08:35 AM
I think it is nothing else than a disguised assembler version of
while (delay_us--);
And I bet there is no 1:1 relation between the contents of
delay_us
, and the time spent there in microseconds...2012-12-19 05:08 PM
Thank you for pointing out c version. But I prefer assembly version to check out which one works closer to 1 microsecond.
2012-12-19 05:43 PM
static void delay_us(uint32_t us)
{
us *= STM32_DELAY_US_MULT;
us--;
asm('' mov r0, us
''
''loop: subs r0, #1
''
'' bhi loop
'');
}
2012-12-20 09:42 PM
Sorry for the late reply.
The following errors are shown when compiled. Do we need to activate any settings in IDE ?The following link may help us to resolve:http://supp.iar.com/Support/?note=31237&%3bfrom=search+result
Thank you2012-12-21 01:58 AM
Don't know the IAR toolchain in detail, but C level variables usually get prepended by a '_' in the assembler/linker stage. I would try '_us' instead.
And I'm not sure, lacking the IAR detailled knowledge, how you tell the compiler that the variable 'us' is manipulated in assembler code.2012-12-21 04:31 AM
I used IAR EWARM 6.40.3.4115, worked there. Why not just put it in startup.s in straight assembler?