Hello,
I am struggling to do something that should be very simple: call an assembly function from a C function. Can anyone give me some pointers or an example of how to do this?
I am using uVision 3 with Realview MDK C compiler.
All of the documentation that I am finding points me to use inline assembly commands. However, this won't work, as I need the assembly code to modify the stack pointer.
Here is what I would like the code to:
void ChangeRegion (void) { asm_adjust_sp(0x78000); //call assembly to change the stack pointer } //asm_adjust_spi(Ulong ulAddress) //1. change stack pointer to 0x4000F000 //2. branch to a the address contained by ulAddress
Any help that you can provide would be greatly appreciated.
Thanks!
Eric,
Are you sure you are using a good startup file?
Hi Tamir,
So for the delay here. We had some fires come up that I had to help take care of.
Actually, I am talking about the IAP/ISP bootloader built into the LPC2300/2400 chips (not a bootloader application). I am passing control to the IAP/ISP bootloader by executing code at address 0x7FFFFFF1.
I have found that launching to this address from supervisor mode is not enough to get the IAP/ISP to take charge of its stack pointer. It will work fine for the first several blocks, but as soon as it gets to a 32KB block, it fails while accepting flash data. However, if I set my stack pointer to point to the top of the internal memory, all is well.
-Eric
I'm thinking about this. will let you know if I come up with something.
I am passing control to the IAP/ISP bootloader by executing code at address 0x7FFFFFF1.
And does it say anywhere in the documentation that this is sufficient to start the bootloader? As opposed to, say, a genuine reset of the microcontroller?
Yes, actually. I am following an example provided in the documentation for doing this. See LPC24xx user manual chapter 30, section 10.