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.

Reading a .txt file on pc line by line and writing on another .txt file

Other Parts Discussed in Thread: TM4C123GH6PM

Hi everyone,

I am trying to write a code for TM4C123GH6PM to read a text file line by line stored in same workspace as that of .ccs project and send it to one of the GPIO pin and also I want it to generate a .txt file for the serial data that it receives through another GPIO pin but even this simple piece of code is not working.


outFile = fopen("C:/Users/Raunak/workspace_v6_1/temp/out.txt","w+");

fputs("This is a system progrqamming language.", outFile);
fclose ( outFile );

Although it generates out.txt file there but the file is blank.

Please suggest me what to do next.

  • Hello Raunak,

    The code is running on a uC which does not have access to PC hard drive/SSD. That is why it will dump an empty file. You need some mechanism like USB to be able to send the data requested by the uC to send to another file. Now where is the o/p going to?

    Regards
    Amit
  • I am trying to implement SCAN Chain based testing mechanism for FPGAs so I want microcontroller to read first line of the input .txt file stored and then sent it to one of the GPIO output pin so that FPGA board (connected to that GPIO pin) can take that vector as input. Then the output generated by FPGA board is sent back to uC at another GPIO input pin which uC can read and generates output.txt . This process repeats till all the inputs stored are given to GPIO output pin and all the corresponding output vectors are stored in output.txt on PC.

    You are correct that code is running on uC and it doesn't have that access but what should I do next. I am not able to find any piece of code where uC does the reading from .txt file and writing into another .txt file on PC.
  • Hello Raunak

    Option-1: Use SD Card on which the txt file can be stored via the PC and then the uC can use the FATFS (Example in tivaware) to read and perform SCAN chain testing
    Option-2: Use USB Thumb drive in a similar manner as Option-1
    Option-3: Use the TM4C as USB Device, and PC as the Host with application that reads a file and sends commands to the TM4C

    Regards
    Amit