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.

SD card not working

Other Parts Discussed in Thread: TM4C123GH6PM, TM4C123GH6PGE

Hello,

I’ve build a system using TM4C123GH6PM with SD card, connected to SSI0 and following the same schematic as in “EK-TM4C123G” kit, by board doesn’t include a UART connection to PC and is not intended to have, I’ve a target of creating txt file and save it in the SD card (as Log files) and read some txt files from SD card (as configurations, modes or settings).

I’m including the SD card example for the kit “EK-TM4C123G” but during the including I got lost as I don’t have a UART terminal connected to computer in this board so I searched a bit in the internet I used the example found in http://elm-chan.org/fsw/ff/en/open.html but I was surprised that the “f_mount” command has more parameters than the one in the included file system.
So I’m really lost, please guide me how to achieve my target (create and read txt files)?

Best regards,
Mina

  • Hello Mina,

    Did you mean the DK-TM4C123G for the sd-card example? If yes, then I would suggest removing the UART print from the code and running the same on a DK-TM4C123 (if you have one) or bringing over the example to your board.

    Secondly, where does your program get stuck?

    If it is about data entry then you can use Windows to format the card for a FAT File System, write a simple text file which has 1 or 0. If 1 then make a RED LED glow or if 0 make a GREEN LED glow. If it is not able to read or gets into a fault then make a 3rd LED glow.

    Regards
    Amit
  • Hello Amit,
    Yes I mean the DK-TM4C123G, I build my board using exactly the same schematics (I triple check it this time) and using the SD-card example. And no I don’t have DK-TM4C123G board I have only the launch pads (the three ones of TM4C123, TM4C129 and CC32300)
    Also yes I removed all of the UART print functions and replaced them by another function that store the data in an internal data array to be able to see it via the debugger (just to make sure that it is working).
    Also yes I formatted an new 4GB SD card to FAT file system and put on it a simple txt file that contains a simple sentence just to read it from the debugger.
    I did that all before writing the post but I got lost because of the following:
    1) I didn’t know how I can pass commands to the system to replace the writing the command on a PC
    2) I did something wrong in porting the code from the example to my code as some functions are enabled on the SD card example and disabled on my code (I was careful in coping the linked resources and adjusting the predefined symbols) ex: _USE_LFN is not defined although I put ENABLE_LFN in the predefined symbols
    3) I didn’t find what is the proper format or proper command to read a txt file for example: “test.txt”
    4) The online reference seems to be different from the provided example
    5) Although SPI pins are at the same positions for SSI0 in both TM4C123GH6PM and TM4C123GH6PGE but I didn’t found a function the initialize the SPI except for “ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);” but nothing for the pin selecting, SPI mode or clock so will it really work?
    6) The available useful commands are: LS, CD, PWD, CAT, in my case I’ll need to use the “CAT” since it reads out a text file, however I didn’t find how to write one (that if I was able to even read a file), and none of the available commands initialize the SD card or SPI, so I must be missing something but I don't know what is it.
    So the above are some of the main reasons that makes me lost, I hope that I have just another simple mistake and it will work.
    Appreciating your efforts and your very effective support that solves my CAN problem in less than 24 hours.

    Best regards,
    Mina
  • Hello Mina,

    One way would be to use UART-1 instead of UART-0 for getting the COM port. However you would need to see how to interface the same to a PC (level translator or a USB to UART dongle). I can help build the application for UART-1 and build in a text reader.

    Regards
    Amit
  • Hello Amit,
    I really have UART 1 connected to external signals, I have already a level translator for RS232, so I can do it but in fact this is not my target because of two reasons:
    1) Final application won’t have UART terminal and SD card operation must be done automatically without human interaction, and it is simple, logging data and reading configuration.
    2) Still I don’t know what is the proper commands to write for example if I need to read “test.txt”:
    a. Will I need to issue: CAT test.txt, CAT “test.txt”, or other form of command
    b. Will the CAT command be the first command to be issued or I must issue other commands perior to it, and if yes what is it?
    So I’d like please to support me to how to pass the commands to original code without PC, the commands will be prewritten in my code, text file name will be constant and known and in a known location (the root).
    If we have other parameters other than name and location of the file we can make it constant also and known and it’ll be great if you can support me in that direction.

    Thank you.
    Best regards,
    Mina
  • Hello Mina,

    You would need to use f_write to write to a file. An example of this is in the usb_stick code in TivaWare, where it searches for the file, if it is present goes to the end and appends to it, or if it is not then it will create one and write.

    What concerns me is that you have no debug mechanism except the debugger (which is OK), but something like UART can help do a lot of run time debug w/o be intrusive with an emulator.

    Regards
    Amit