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.

RM57L HDK change SPI clock

Other Parts Discussed in Thread: HALCOGEN

Hello,

I'm trying to communicate with the SD card (SD slot is connected on the board). It is connected via mibspi2.

In HALCoGen I've activated the mibspi2 driver and checked in the pinmux if there were no conflicts.

Then I've set the Baudrate from Data Format 0 to 400kHz (because this frequency is for the SD card to reset it's internal registers).

In the main program first I've to send 10 dummy bytes to the SD card and then send CMD0 wtih crc = 0x95.

Then do some polling with CMD55 and ACMD41 to check if the SD card is in idle mode. After this the card is ready to receive general commands.


Now I want to set the SPI clock speed higher, because I want to transmit data at maximum speed allowed.

My question is: How can I change the mibspi2 it's clock when the program is running?

Kind regards,

Jason

  • Jason,


    It is true that the SPI driver does not provide an API to change the baudrate.

    So here are 2 options that you can use.

    1] You can take advantage of the Data Format and define Data Format0 with a low baudrate during initialization of the SD card and switch to Data Format 1 (with a higher baudrate)

    2] Use only Data format with a default low baudrate and when the SD card is initialized, change the baudrate has following:

    // set the SPI speed to the max setting
    static
    void set_max_speed(void)
    {

          spiREG1->FMT0 &= 0xFFFF00FF;   // mask out baudrate prescaler
                                                                          // Max. 5 MBit used for Data Transfer.
          spiREG1->FMT0 |= 8 << 8;                // baudrate prescale
    }


    The value 8 is an example. Based on your VCLK you will have to calculate the correct prescaler for the baudrate you want to achieve.

  • Jean-Marc,

    Thank you so much for your response! This helped me so much!

    Best regards,

    Jason