f_write without char data types
Good day everyone,
I have a slight issue, I'm storing data in the form of uint16_t data types.This data will be read in from an ADC and have values of 0 and 1. I'll have an array of 192 of these 16 bit values that I'd effectively like to store in a SDcard. The problem is that I can't directly send these to the sdcard using fwrite as it would be completely unreadable, so I'd need to convert it to a char datatype.
It seems a little counter-intuitive as char are 8 bit long and I'd need to cast 192 of these 16 bit unsigned integers.
I tried doing a cast to wchar_t and it works perfectly in the code. I can cast a uint16_t value to a wchar_t without it seeming at all computationally expensive, although when I try to send this to f_write and send it out I get complete junk.
Is there any computational inexpensive way that I can get a uint16_t array[192] into a readable format for text or binary files?Here's a code snippet of what I've used:
uint16_t aDST_Buffer= 1100;
wchar_t Conv; Conv =(wchar_t)aDST_Buffer; //This gives me Conv = 1100 res1 = f_write(&SDFile,&Conv , sizeof(Conv ), (void *)&wbytes); // This produces a large amount of junk.I've seen some examples where they pass the data directly and not the address, I also tried that out of desperation without any success:
uint16_t aDST_Buffer= 1100;
wchar_t Conv; Conv =(wchar_t)aDST_Buffer; //This gives me Conv = 1100 res1 = f_write(&SDFile,Conv , sizeof(Conv ), (void *)&wbytes); // This produces a large amount of junk.It doesn't seem that unicode is supported.
Thanks in advance for any help!
#fatfs #wchar_t #f_write #stm32f7