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.
Hi guys,
I'm trying to port the code from TivaWare_C_Series-2.0.1.11577/examples/boards/dk-tm4c123g/sd-card/sd_card.c to work on my TM4C123G Launchpad. I'm using functions from /port/mmc-dk-tm4c123g.c (MMC/SDC control module).
I'm using this breakout board https://www.sparkfun.com/products/11403 with the following connections;
D3 (chip select) - PA3 (SSI0Fss)
CMD (MOSI) - PA6 (SSIOTx)
DO (SOMI) - PA4 (SSIORx)
CLK - PA2 (SSI0Clk)
Currently I'm getting an error in the disk_initialize function and as a result I get FR_NOT_READY when I try to create a file on the SD-card. As I'm also using SSI0 on my Tiva I'm not sure what I need to change in the initialization to get this code to work. As far as I can see all the port configurations are the same across both boards? My main function is below,
int main(void) { int nStatus; FRESULT iFResult; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the system clock to run at 50MHz from the PLL. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Configure SysTick for a 100Hz interrupt. The FatFs driver wants a 10 ms // tick. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Enable Interrupts // ROM_IntMasterEnable(); // // Initialize the UART as a console for text I/O. // ConfigureUART(); UARTprintf("\n\nSD Card Example Program\n"); UARTprintf("Type \'help\' for help.\n"); // // Mount the file system, using logical disk 0. // iFResult = f_mount(0, &g_sFatFs); if(iFResult != FR_OK) { UARTprintf("f_mount error: %s\n", StringFromFResult(iFResult)); return(1); } power_on(); BOOL a = wait_ready(); DSTATUS errd; if(a) { send_initial_clock_train(); errd = disk_initialize(0); UARTprintf("\nInitialising disk 0. Status = %i\n", errd); } FIL fil; uint32_t count = 8*512; iFResult = f_open(&fil, "testfile.txt", FA_CREATE_NEW|FA_WRITE); SysCtlDelay(SysCtlClockGet()/3); if(iFResult != FR_OK) {UARTprintf("fresult: %s\n", StringFromFResult(iFResult)); } else{UARTprintf("\n Opened SD card\n");} iFResult = f_write(&fil, "Hello world", 11, &count); if(iFResult != FR_OK) {UARTprintf("Error writing to file: %s\n", StringFromFResult(iFResult));} iFResult = f_close(&fil); f_mount(0, NULL); }
Any help appreciated.
Hi James,
Here below is the circuitry of SD Card to DK-TM4C123G, taken from the schematic at the User's Guide. Do you connect this Sparkfun Breakout board for SD Card, the same? Does your circuitry have pull-up resistors and others as illustrated below?
Also, since you are importing the SD card example to Tiva Launchpad, make sure there are no problem with Peripheral addresses and others.
With regards to project settings, you need set the Preprocessor symbols appropriate for Tiva Launchpad.
-kel
Hi there, I actually also doing the same thing, I looked at your code and see you are using the functions from the mmc file, power_on, send_initial_clock_train and wait_ready. however, i ran into some problem regarding linkers. when i try to build, they said there was unresolved symbols. mind helping out?
unresolved symbol send_initial_clock_train, first referenced in ./main.obj SDcard C/C++ Problem
unresolved symbol wait_ready, first referenced in ./main.obj SDcard C/C++ Problem
unresolved symbol power_on, first referenced in ./main.obj SDcard C/C++ Problem
Hello Hong
please zip and attach the cs project so that we can check why linker is failing
Regards
Amit
Hi Hong,
James imported a working example project to CCS. Did you do the same?
The errors above means you have not setup the paths for your project at CCS.
Download the workbook pdf from the link below. There is a part there that discusses creating a new CCS project from scratch. Maybe, you can get an idea how to solve those linker problems yourself. Take note that this workbook pdf is for Tiva Connected Launchpad.
-kel
Thanks for the quick reply. I have attached the zip file of the folder. i will also be looking at markel suggestion to import in the project.
Hello Hong
I am unable to import the file in CCSv5.5. It is giving me an error stating that the metadata is not correct. Can you let me know which version of CCS are you using?
Regards
Amit
Hello Hong,
Now I have to upgrade to CCSv6 as well.... This will take time...
Regards
Amit
Hello Hong,
I simply imported the sd-card project from examples. It works.
Regards
Amit
Hi amit,
Do you mind running through importing the project? First, I imported via Project -> Import CSS Project -> Navigate to C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\dk-tm4c123g\sd_card\. Then in the code, I remove the code that I do not need which include the displaying and cmd, leaving with the sd_card writing. Do I need to change the include options settings and the compiler since the EK is using a TM4C123GH6PM instead of the DK's TM4C123G6PGE?
Hello Hong,
Yes. The PART_xxx define during compilation needs to be changed. Other than that GPIO Pin map changes need to be incorporated. Once this is done, first run the unchanged code before making any further modifications.
This will help isolate the issue.
Regards
Amit
Hi Amit, after going through step by step to import the file, the sd card is writing all good now. thank you very much for your kind assistance.
Regards,
Rey
I have another question in this sd_card topic.
Can I remove cc932.c file , as it uses too much space? There is a define line:
"#error This file is not needed in current configuration. Remove from the project."
It would be the solution of error:
".\rvmdk\sd_card.axf: error: L6047U: The size of this image (43308 bytes) exceeds the maximum allowed for this version of the linker"
But I'm concerned if removing of this partition table will spoil the project?
I'm having problem with SDCard libraries, i can't get them right or from the right place
Hi Victor,
There is already an sd_card example at Tivaware. So just import the project to your IDE. Are you using CCS?
- kel
Yes, im using CCS v5, but the example is using USB and its reading, not writing.
I need a simple code to use SSI3 PD ports SPI, just to store a array of values in the same line, separated with a coma, each 100ms or so.
I already changed the library to config the SSI0 to SSI3.
Im using a TM4C123G6PMI.
I can't find simple examples to add to my code. Im also using a GLCD and SSI in other 2 Tiva's.
My code is based on this librarie.
Google this name
madvoid/Tiva-Test
Also, i only managed to put it working with a sd card of up to 4GB you can't use SDHC card.
Do you think there is a way to port this code to the CC2650 sensor tag?
Thank you,
Alejandro