cancel
Showing results for 
Search instead for 
Did you mean: 

Modyfing/replacing C funtion during STM32 work

kubakotlorz
Associate II
Posted on December 17, 2012 at 14:48

I'd like to implement simple DSP job on my STM32F4 discovery board. I wish to have possibility to change it during STM32 work without flashing program memory. Can I do that?

It's like I compile some C funtion to my library, send it to target (via usb), who will update/substitute DSP processing function to the new one saving in into the SRAM. C language recognise function as an address of its beginning, right? I would implement like two SRAM spaces for two functions I will switch between them every time new one is completely copied into memory.

STM32 will constantly gather some input data (but NOT from USB-key), process it with my DSP function and sent it back to Codec that I will add to my target, don't worry about hardware now.
3 REPLIES 3
Posted on December 17, 2012 at 15:34

Indeed you can call a function pointer, and that pointer can be in RAM. Be aware however that the Cortex-M3 is going to expect a ODD address seeing as it's is using Thumb code. Thus while you load code at say 0x20003000 you'd call 0x20003001.

Observe how you pass function pointers in to things like qsort() if you need an example.

You cannot use CCM memory on the F4 series parts for code execution, but it will work on F3's

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kubakotlorz
Associate II
Posted on December 17, 2012 at 22:35

STM32F4 is required. Do you have other solution for me?

Posted on December 17, 2012 at 22:48

STM32F4 is required. Do you have other solution for me?

Ok, so use the regular SRAM (0x20000000), I just said you couldn't use the CCM (64KB at 0x10000000) to execute code.

Carve out some space, copy your routine(s).
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..