Not applicable
Mar 03, 2016
02:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 03, 2016
02:00 AM
Hi
I'm trying to print 3 variables on an SD card .txt file each script cycle. For that I need to pass a string in the f_write() function, so I want to use the sprintf() function to insert the variables in the string.
The code I'm using is something like this (it is based in the FATFS APP example):
The problem is that this doesn't print anything more than ",," in the buff[] string. After the ",," there is a lot of garbage (the other 20 elements), but in the middle there's nothing.
This code works fine on Visual Studio, but not on DAVE...
Thanks in advance.
EDIT: I've tested now the sprintf() function with ints instead of floats and it works. It just doesn't like floats...
I'm trying to print 3 variables on an SD card .txt file each script cycle. For that I need to pass a string in the f_write() function, so I want to use the sprintf() function to insert the variables in the string.
The code I'm using is something like this (it is based in the FATFS APP example):
char buff[22];
float Vo = 4.216;
float i = 0;
float soc = 100;
sprintf(buff, "%.5f,%.5f,%.1f", Vo, i, soc);
res = f_write(&fil, &buff, 22, &bw);
The problem is that this doesn't print anything more than ",," in the buff[] string. After the ",," there is a lot of garbage (the other 20 elements), but in the middle there's nothing.
This code works fine on Visual Studio, but not on DAVE...
Thanks in advance.
EDIT: I've tested now the sprintf() function with ints instead of floats and it works. It just doesn't like floats...
2 Replies
Mar 03, 2016
02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 03, 2016
02:36 AM
Hi,
You will need to enable "Add floating point support for printf" in the Project properties > ARM-GCC Linker > General.
Best regards,
Jesus
You will need to enable "Add floating point support for printf" in the Project properties > ARM-GCC Linker > General.
Best regards,
Jesus
Not applicable
Mar 03, 2016
02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 03, 2016
02:48 AM
Thanks Jesus! It is working now!