This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235SF: How to save data in a txt file

Part Number: CC3235SF


Tool/software:

Hi, I'm reading and ADC from CC3235SF and I need to save the Serial Monitor data into a txt file. How can I do it? 
I tried doing it same as normal C, but it just doesn't create the file. No errors, no warnings, but the txt file doesn't get created. Don't know why. 
I'm using the following function I created, I tested them  in VS Code and it works, but in CCS I think I need to do something else. Can you help me?


void escribir(uint32_t numero){


filePointer = fopen("C:/Users/krlos/Desktop/lectura_adc.txt", "a");

if (filePointer == NULL) {
printf("Error al abrir el archivo.\n");
}

fprintf(filePointer, "%u\n", numero);


 fclose(filePointer);

 printf("Número escrito en el archivo con éxito.\n");
}

  • Hi,

    No. This will not work. You need to realise that you are working with embadded device - MCU and not "big" computer. At CC32xx you can use sl_ filesystem APIs which save data into SPI flash. But be carefuly. SPI flash have limited number of write cycles. It is not intended for datalogging purpose. High number of write cycles (100k/sector) will damage SPI flash permanently. For more details about APIs see SWRU455 or Simple link academy.

    Jan

  • Thanks for your answer! I'll keep it in mind. But what if I dont want to save data into SPI flash? I cheked some functions like sl_FsOpen and sl_FsWrite, does that allow me to create txt files and save data?

  • Hi,

    If you want so save data, you need some non-volatile storage. At CC32xx is no other storage than SPI flash.

    But nothink prevent you connect your own storage to CC32xx like FRAM, EEPROM, SD card. Management of this storage will be up to you.

    Jan

  • Ok, thank you so much! That means I can´t create txt files from CC and save it in my computer, right? Now I'm testing the possibility of reading the serial port with Python and save that text in a txt. Do you think is a viable option?

  • Hi,

    You can do what you program. This is up to you.

    Jan