Hello all again;
I want to ask for your help to understand this problem. I need to make a converter from float value to string, to be send by serial transmit of my Tiva C launchpad. Im trying to make the conversion in a simulink function block using the sprintf function.
During the debug in the Code Compiler Studio it works fine, I only receive a warning that the return variable are not compatible with the format, but the value gets saved to the char variable.
The problem ocurr with Matlab, because regardless the value of the constant, the block always give me the value of -128; I was searching for hours, but i can't found any solution.
This is the C code:
#include <stdio.h>
#include "dobloh.h"
double u;
char doble(double u)
{
static char car[2000];
sprintf(car,"%.3f",u);
return car;
}
"dobloh.h" Header:
#ifndef DOBLADOR_C_ #define DOBLADOR_C_ char doble(double u); #endif /* DOBLADOR_C_ */
Function block code:
function y = callingDoblez(u)
%#codegen
y=0.0;
y = coder.ceval('doble',u);
Diagram:
I hope you can help me to understand the problem,
Thanks for your time
Regards
Alberto

