cancel
Showing results for 
Search instead for 
Did you mean: 

SAVE MEMORY CONTENTS TO A FILE for STM32F3

love-peace2001
Associate II
Posted on January 29, 2014 at 17:00

Hi all;

I'm working with the discoveryF3  board, i'm using the ST-Link debugger.

I want to save two float arrays into a file when debugging.

My IDE is µVision4.

I found that the command ''save'' can do that  but when i used it, i have wrong values.

Someone has an another technique to this stuff.

Thanks in advance
10 REPLIES 10
Posted on January 29, 2014 at 17:39

SAVE is pretty much the way to do this, it outputs Intel HEX format which complicates post processing a little. Then again you're using float's which should be decodable by a Windows based compiler or otherwise using the IEEE-754 format.

Other methods would perhaps to be save it onto an SD card attached to the system, or stream out via the serial port in a manner/format that suits you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on January 30, 2014 at 13:52

Thank you clive1 for your quick response.

what about ''fopen'' and ''fwrite'' ? we can't use them to open and write into a file ?

Posted on January 30, 2014 at 16:37

what about ''fopen'' and ''fwrite'' ? we can't use them to open and write into a file ?

Where would such a file go, and what code do you have to support that operation? This is embedded, unless you've implemented some file system or OS it's not happening.

You could output data via a serial port, or the SWV (View -> Serial Windows -> Debug (printf) Viewer) on the PB3 pin with SB10 bridged.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on January 30, 2014 at 17:39

''unless you've implemented some file system''

How can i implement file system ? it will be great.

''You could output data via a serial port'': yes i have tried to do that but no success, the communication works but when i send or receive data, i get wrong values so i dropped.

Ideally, i want to store my two arrays into a file and then plot them with excel for example. 

Posted on January 30, 2014 at 19:59

Not sure why you have a problem with serial. Remember the STM32 uses CMOS levels, and won't connect directly to RS232 devices. You might want to look at USB-To-CMOS Serial type devices (FTDI, SiLabs, Prolific, etc)

File systems, on an STM32F3-Discovery you'd had to add an SD card socket/interface, add code to support that, and then add a file system like FatFs

If serial is a challenge, consider using the SWV

http://www.keil.com/download/files/swv_on_cortex-m3.pdf

http://www.keil.com/download/files/labst.pdf

It works on the ST-LINK used on the STM32F3-DISCO board, you just need to bridge SB10 on the back to get the pin connectivity

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on February 03, 2014 at 18:26

Hi again, 

Thanks you clive1 for your help, i appreciate it.

I use the SWV it works fine for simple data like printf(''hello word'').

But when i want to print my two float arrays, i can't get all my data,my arrays are both 1024 samples, it jumps some value and i don't know why, for example it shows some thing like this:

k=0        MES_1: -0.483102              MES_2: 0.347957 

k=1        MES_1: -0.585388              MES_2: -0.821821 

k=2        MES_1: -0.585826              MES_2: -0.821255 

k=3        MES_1: -0.586605              MES_2: -0.819777 

k=4        MES_1: -0.586402              MES_2: -0.819633 

k=5        MES_1: -0.586548              MES_2: -0.821310 

k=6        MES_1: -0.586817              MES_2: -0.821821 

k=7        MES_1: -0.586755              MES_2: -0.821742 

k=8        MES_1: -0.588197              MES_2: -0.819091 

k=9        MES_1: -0.588505              MES_2: -0.818651 

k=10        MES_1: -0.588773              MES_2: -0.817754 

k=11        MES_1: -0.589459              MES_2: -0.823334 

k=12        MES_1: -0.589924              MES_2: -0.818838 

k=13        MES_1: -0.592064              MES_2: -0.820421 

k=14        MES_1: -0.590832              MES_2: -0.817722 

k=15        MES_1: -0.591669              MES_2: -0.816614 

k=16        MES_1: -0.592894              MES_2: -0.816938 

k=17        MES_1: -0.594940              MES_2: -0.815876 

k=18        MES_1: -0.595303              MES_2: -0.814116 

k=19        MES_1: -0.596574              MES_2: -0.814893 

k=20        MES_1: -0.597424              MES_2: -0.814350 

k=21        MES_1: -0.598700              MES_2: -0.813246 

k=22        MES_1: -0.599896              MES_2: -0.812544 

k=23        MES_1: -0.601454              MES_2: -0.813172 

k=24        MES_1: -0.602724              MES_2: -0.810391 

k=25        MES_1: -0.602640              MES_2: -0.811990 

k=26        MES_1: -0.604783              MES_2: -0.810818 

k=27        MES_1: -0.605809              MES_2: -0.808267 

k=28        MES_1: -0.608684              MES_2: -0.808539 

k=29        MES_1: -0.609863              MES_2: -0.806906 

k=30        MES_1: -0.609863              MES_2: -0.805966 

k=31        MES_1: -0.611337              MES_2: -0.807800 

k=32        MES_1: -0.614956              MES_2: -0.803744 

k=33        MES_1: -0.615910              MES_2: -0.802969 

k=34        MES_1: -0.616941              MES_2: -0.804142 

k=35        MES_1: -0.619237              MES_2: -0.801086 

k=36        MES_1: -0.620757              MES_2: -0.799753 

k=37        MES_1: -0.625475              MES_2: -0.802851 

k=38        MES_1: -0.624527              MES_2: -0.798632 

k=39        MES_1: -0.626367              MES_2: -0.795911 

k=40        MES_1:     MES_1: -0.521140              MES_2: 0.329964 

k=233        MES_1: -0.510823              MES_2: 0.336236 

k=234        MES_1: -0.503895              MES_2: 0.334139 

k=235        MES_1: -0.492707              MES_2: 0.340790 

k=236        MES_1: -0.480857              MES_2: 0.345976 

k=237        MES_1: -0.470579              MES_2: 0.351589 

k=238        MES_1: -0.461573              MES_2: 0.355391 

k=239        MES_1: -0.450505              MES_2: 0.356636 

k=240        MES_1: -0.441443              MES_2: 0.350977 

k=241        MES_1: -0.430641              MES_2: 0.366206 

k=242        MES_1: -0.425337              MES_2: 0.352911 

k=243        MES_1: -0.411351              MES_2: 0.367043 

k=244    40        MES_1: 0.321546              MES_2: -0.211932 

..........................

........................ 

Do you have an idea what would be the problem  ? i miss some configuration of the Trace ?

Thanks in advance 

love-peace2001
Associate II
Posted on February 03, 2014 at 18:29

I would know if it possible to export value showed in one of the memory (memory1,2,3,4) to a file 

Posted on February 03, 2014 at 18:36

The SWV implementation has a finite buffer in the ST-LINK (J-LINK not much better), you might want to stop periodically. Serial is better for this because you can use flow-control.

If you copy (or have) your memory buffers in a known location like 0x20003000 you can SAVE that buffer. SAVE might also recognize symbols, although I've not used it in that fashion.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
love-peace2001
Associate II
Posted on February 03, 2014 at 22:43

And then how can i convert the Hex to float? do you know a software tool that can do this please ?