scanf/printf not working when calling generated C code
61 views (last 30 days)
Show older comments
In Matlab I have generated C code (.c/.h files) from a Matlab function using codegen from Matlab Coder.
I call this function in a while loop on an ARM quad-core Cortex A53 using AMD Vitis.
Before calling this function I use scanf/printf to get user input and to print to the serial monitor. However, scanf/printf only work once in the 1st iteration (before calling the function) and not in the 2nd iteration or later (after calling the function).
Is this a common problem and has anyone encountered this problem before?
I think, but am not sure, that the problem is in the generated C code and not in Vitis itself.
Thank you in advance!
7 Comments
dpb
33 minuten ago
Without the actual code, it's not possible to say anything definitive. The internal variable definitions and typing and possible conversions and how are retrieved/saved in memory and addressed in the calls are the critical points and cannot be determined explicitly without the code itself.
That a literal string does work and the floating point variable doesn't is pretty definite indication there's a mismatch in there somewhere between what is being passed and what the function prototype is expecting. It's possible there's a mismatch in the default floating point size type in the compiler flags other than inside the code itself, too, you need to confirm what the compiler is being told.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!