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.

CCS: Writing data into Sd Card

Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello, i'm a begginer in programming Texas' DSPs. Actually i'm using the C2000 Delphino Launchpad e I would like to write the data from ADC's into Sd card. There's an exemple in the C2000 Ware, but it uses UART communication and the part of writing data into Sd card is not much clear to understood. I would like to know if there's another code that I could use to understand the concepts and the whole process!

Regards,

Eduardo.

  • Eduardo,

    I don't think we have UART based communication write protocol with SDcard. Are you talking about EMIF based example code?

    Please provide the C2000Ware path of the example code you are talking about?

    Regards,

    Manoj

  • The UART communication is just used to provide a user interface for interacting this the example. It's not necessary for the the actual reads and writes to the SD card. The communication to the SD card is actually done over SPI. The mmc_F2837x.c file contains the SPI code if you wanted to study it.

    The only other example we have is this old app note. It doesn't have the file system that the C2000Ware example does, but it might help explain the concepts better.

    http://www.ti.com/lit/pdf/spraao7

    Whitney

  • For sure, I was unclear about that. That code had a UART interface, but it's just to enable the user to send commands to the C2000 through the serial. Thanks for your attention !!

  • Nice, I've used this docs to make the system work. I'm currently able to write data to SD card, but I'm having problems about the speed of writing.

    The system is for motor control, and the control loop works in 10KHz. In each cycle it's needed to write the value of five floats. The f_write () function takes 8% from the total time of a loop, which is pretty good. But, to flush the buffer, the f_sync () function takes about 100 cycles, which does not enable the control loop to be continuous.

    I'm not able to achieve heigher frequency than 12.5MHz in SPI SCLK, even setting the registers from clock and spi to the max clock possyble.

    Thanks for your attention !!

  • Is it possible to move the SD card communication out of the control loop? Have them run in the background or in a lower priority interrupt?

    I'm not sure what speed your SD card can tolerate, but the F28379D SPI can run at a max speed of 50MHz. You'll need to change the LSPCLK frequency, turn on high speed mode, and look into whether or not you're using a pin mux option that allows it. You can look into the data sheet for details.

    Whitney

  • Hello Whitney! I'm really thankfull for your attention in my problem.

    I've been able to achieve frequencies up to 50MHz (using the correct pin mux and the high speed mode), but the SD card isn't able to work correctly in such frequency. Just a doubt, enabling the high speed mode and setting SpiaRegs.SPIBRR.all = 1, should not I been able to achieve frequencies higher than 50Mhz?

    In order to solve the problem, I thought in two solutions:

    - Utilize the second cpu to execute the f_sync() process, keeping to the first CPU just the task to fill two buffers (ping-pong style) and send to the second one the desired data, It's good because could be able to achieve high performances, due to don't spend clocks from first CPU to execute the write. But it's been really hard, because to inicialize the communication with the SD card, it's needed to mux the pins of SPI (trought the CPU1) while the SPI-A clock is enable, witch is a problem because after the clock been initialized, cannot be transferred to the domain of CPU2 (at least is what I've read about).

    - Use the solution smartly proposed by you, witch consist in keep the control process inside the interrupt function and execute the SPI writing process outside it. But I don't know how to do it's. Maybe keep the writing routine in main() function and keep the interrupt would stops this process and performances the control process in real time.

    I'm stucked with this problems a aprreciate so much your help.

    Again, really thank you for your attention!

    Best regards,

    Eduardo Cattani.

  • No, 50MHz is the limit. If you look at the description of BRR in the reference manual, it says that values of 0, 1, 2, and 3 all result in LSPCLK/4.

    I think either one of those solutions could work. For your first option, is it possible to do the initialization on CPU1 and then transfer ownership to CPU2 for the actual writing during run time or have you found some limitation that prevents that?

    Whitney

  • Yes, after the clock on the SPI-A is enabled it's not possible to transfer the ownship. I'm running the write operations in main(), which is a background operation, because the interrupt from EPWM stops the process. But I'm having another problem: i'm not able to decode de float written. I'm directly writing the float into 4 bytes and the output is unreadble.

    Example:

    "

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » » Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z z Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ Œ

    "

    I know that it's in UTF-8 but i'm not able to decode it. Would you know how do it?

    Thank for your attention!

    Regards,

    Eduardo.

  • You'll have to convert it from raw float to an ASCII string at some point I think. You could do it on the C28x using sprintf or some other means of conversion and send the characters to the SD card instead.

    You could also write a utility that runs on your PC to post-process the data from the SD card and do the conversion there--that is assuming that you're logging the data with the intent of analyzing it on a PC anyway, but correct me if I'm wrong.

    Whitney

  • Thank you for your attention, Whitney!

    I did it and now I'm able to read the 8-bit Hex data from memory.

    I wrote an array of floats into SD card, and I did a post-process script to transform the raw data written in SD to float.

    But i'm stuck in conversion from Hex to float, because it seems to lack data.

    For instance, the number 0x3DCCCCCD is stored in memory like this 0xCCCD 0x3DCC (16-bit-Hex) or 0xCD 0xCC (8-bit-Hex). In the script I'm able to extract the 0xCD 0xCC, but its 4 hex numbers means 2 bytes or a half of float. In 16-bit-Hex representation it has 8 Hex, which means 4 bytes or a full float.
    I don't know how to proceed, because it seems to not be the full data from the number what I'm extracting.

    When it's changed the format of view in memory browser from 16-bit-hex to 8-bit-hex does some data is lost?

    Best regards,

    Eduardo Cattani.

  • I'm not sure I'm following exactly. Are you saying that the upper byte of each 16-bit word is going missing? How are you splitting the float into bytes for sending? Do keep in mind that the C28x is not byte addressable and that the smallest data type we support is 16 bits, so you'll need to do some shifting, use the __byte intrinsic (see the compiler user guide if you aren't familiar with it), or use bit-fields to access each byte separately.

    Or perhaps not understanding the issue? Can you try giving another example? Maybe share some screen shots?

    Whitney