Skip to main content
Visitor II
October 11, 2022
Solved

Need help with passing a float array into a function to transmit floats out of USB port.

  • October 11, 2022
  • 1 reply
  • 1779 views

I'm trying to transmit a 4D array of floats from an stm32l552zet6q to a PC using a USB connection. I can collect the array elements and store them, but when I pass the array into the transmission function, I don't see the same elements.

This image is of the array values as they should be, and are when outside the sendData and sendMatrix functions.

0693W00000UnqDjQAJ.pngAnd this image is what arrives inside the sendData/sendMatrix functions:

0693W00000UnqE8QAJ.png0693W00000UnqEIQAZ.pngAdditionally, I cannot get sprintf to format a string with ANY float values, as shown in the below screenshot

0693W00000UnqErQAJ.pngThe test matrix I've declared is a local variable with a defined size (test[4][35][42][3]).

I've tried altering the code to instead use pointers to the test matrix, but I get the exact same results, though it's entirely possible I was using them incorrectly. Any assistance is appreciated.

    This topic has been closed for replies.
    Best answer by ESpra.1

    Found the final problem. At some point, I'd accidentally changed configuration from debug to release, and did so before enabling the sprintf float option. So, whenever I fired up debug, I couldn't send any float information. I switched back to debug, re-enabled the float sprintf option, and everything is working

    1 reply

    Graduate II
    October 11, 2022

    Make sure floating point (s)printf() functionality has been enabled and the correct libraries selected. By default I think it's disabled to keep the code foot-print low. There's been 1000's of such posts, you should be able to find some suggestions or tutorials.

    Some of the debug screens seem to should addresses of pointers

    Check that the sizeof() for the array matches expectations of size vs dimensions.

    It should be possible to pass the data as a block, and be able to memcpy() it

    ESpra.1Author
    Visitor II
    October 11, 2022

    I do have that functionality enabled (CubeIDE pestered me about it when it wasn't). I'll recheck the posts as well while I'm trying your suggestions. Thanks for the quick response!

    That said, I am confused why the debug screens would be showing the addresses of pointers, since they don't do anything like that in other functions where I pass the same array in to set the values; It's all zeroes there. The main difference is that I'm setting the values in the one function, and putting those values into a string in the other, but I'm lost on why that would change the appearance of the array when I enter the other function.