We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm trying to use inline assembler code but the keyword '__asm' is not accepted. I can create an '__asm' function with no compiler warnings but when calling this function the uC restarts. Using Cortex M3 device.
Regards,
Henk
Use only this format - called embedded assembly:
__asm void delay(int32u a_microseconds) { loop SUB R0, R0, #1 CMP R0, #0 BNE loop BX LR }
Forget about inline assembly altogether! See your manuals for details about the differences.
Why?
>why?
I have to write a bootloader for the STM32F103ZE. The bootloader writes received data to the main flash area. The flash data only is accepted if written as a 16-bit value. I tried using a short (16-bit) pointer but somehow that does not seem to work. I allready wrote a bootloader for some 8051 controller so I thought assembler would be the easiest way to do.
But I'm open to other ideas.
"I tried using a short (16-bit) pointer but somehow that does not seem to work."
You might want to investigate why you can't get your existing code working. You might get some help on that.
or did you mean: why 'only'?
At my boss compiling under WinXP causes the mentioned trouble. Compiling at home under Vista does work fine. (I ment using __asm function)
So what's going on...?
Inline assembler is complaining about 'Thumbs' so I think I have to study this item first.
Executing the flash sequence like unlocking all works fine. If I erase some flash section containing code then the verify function shows that code has changed. If I erase the lowest page containing my small test application then is does not start on reset because it is erased.
When writing data to flash memory the verify function reports that verify is okay, which should not be so if data was really written to flash.
This is my write function:
void vWriteAddressX16BitsValueY(int iAdd,short sDta){ //var short* sp; //select address sp=(short*)iAdd; //write data *sp=sDta; }
Checking some flash write error bit shows that no error occured. But as said: no dat is written.
As far as I know, you cannot write into internal flash like this. Did you check your user manual - are you allowed to write into flash like this...? On a LPC2478, this will cause an immediate failure. If not, you need to search your user manual for "IAP".
And you don't need any assembly to write a bootloader, at least not on a LPC2467/78/1768 !
>As far as I know, you cannot write into internal flash >like this. Did you check your user manual - are you
Yes you can, but first have to follow some unlock sequence which works fine otherwise it would not be possible to erase pages as is done.