Other Parts Discussed in Thread: CC3120MOD, CC3120, UNIFLASH
Hello,
I am working on a project using an MSP432 and CC3120MOD.
I was looking at using the nonvolatile memory on the CC3120 to create a testing program that will count every time the MSP432 wakes up from LPM before going back to sleep.
I am able to create and write onto files just fine. When I download a created file via uniflash, I can see the text put into the CC3120 file by using notepad.
However, when I read a file from the CC3120, the text seems to be distorted from what is actually on the file. For example, if I write "Testing CC3120" to a file using either notepad + Uniflash or the MSP432, the MSP432 input buffer will read "eesiigg C31120�". I made sure to check the file again by re-downloading from the CC3120 via uniflash, and the text looks to still be perfectly in-tact in the file it is reading from.
In the case of my counter, when I read "00001" off of the CC3120 file from the MSP432, the input buffer is showing up as "00011", which completely breaks my program. I did double check that the counter system works by downloading this file again, and the text contained was "00001".
I think it is an issue in the way I am using sl_FsRead() or sl_FsOpen(), but I am not sure. I will include the code for reading/writing I am using below.
Thanks,
Greg
char* DeviceFileName = "lpm_count_hex";
unsigned long MaxSize = 63 * 1024; // Bytes
long DeviceFileHandle = -1;
char InputBuffer[50];
char OutputBuffer[50];
long count;
DeviceFileHandle = sl_FsOpen((unsigned char *)DeviceFileName,
SL_FS_READ,
NULL);
sleep(1);
ret = sl_FsRead( DeviceFileHandle, 0, (unsigned char *)InputBuffer, 50);
UART_PRINT("%s", InputBuffer);
count = strtol(InputBuffer, NULL, 10);
count++;
sprintf(OutputBuffer, "%05lu", count);
sleep(1);
ret = sl_FsClose(DeviceFileHandle, 0, 0, 0);
sleep(1);
DeviceFileHandle = sl_FsOpen((unsigned char *)DeviceFileName,
SL_FS_WRITE,
NULL);
sleep(1);
ret = sl_FsWrite(DeviceFileHandle, 0, OutputBuffer, 5);
sleep(1);
ret = sl_FsClose(DeviceFileHandle, 0, 0, 0);