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.

spi clock issue

Other Parts Discussed in Thread: SYSBIOS

Hi Sir:

I use AM335x IDK board and am335x_sysbios_ind_sdk_1.1.0.8 to do a test.

I use mcspiflash example that is in starterware directory to try adjust the clock rate of SPI.

The picture below is that I do not adjust the clock rate of SPI and I transmit 8 bytes data. 

Ch3 : Clock Ch2 : Data Ch3 : CS

 

The picture below is that I adjust the clock rate of SPI to 1MHz and I transmit 8 bytes data.

However I only see 6 bytes data in oscilloscope.(I only change the value of MCSPI_OUT_FREQ to 1000000 in mcspiFlash.c)

 

Ch3 : Clock Ch2 : Data  Ch3 : CS

 

Could you give me some suggestion?

Best regards,

 

Marcus

  • I think there is slight flaw in the counter code The length counter tracks the number of bytes transmitted but the receive code uses the same counter to stop the SPI. I think what you are seeing
    - 6th rx word is being received
    - 7th tx word is loaded into shift register
    - 7th tx word is about to be shifted out
    - 8th tx word is loaded into shift register, length = 0
    - 6th rx word is ready to be read, if length = 0 then flag = 0
    - mainline code sees flag=0 and disables SPI before 7th and 8th are really transmitted.
    A possible fix would be to use a separate length and flag variable for transmit and receive. The McSPITransfer() function should wait for both transmit and receive to finish.
  • Hi Norman :

    I appreciate your reply!

    I now can get the correct response, however I get another question.

    The initial state of SLK is low when power on and I need to issue a spi read command to enable SLK in high state.

    I need the SLK in high state after power on, could you give me some suggestion?

    Could I do this by modifying SPI register(I have saw TRM, but I do not get any clue) or by hardware?

    Best regards,

    Marcus
  • I do not have any direct experience with the AM335X. If it is like other processors, you have to modify the phase and polarity. The StarterWare API is McSPIClkConfig(). Try changing MCSPI_CLK_MODE_0 to MCSPI_CLK_MODE_1, MCSPI_CLK_MODE_2, or MCSPI_CLK_MODE_3. Prior to executing McSPISetUp(), your lines will be undefined. If you need to have the lines in a known state before that function, I would guess that you will need some pull up resistors. Hardware is not my field.

    That's all I can suggest. Please start another thread for new questions. A new thread will attract more attention.