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.

Code Compilation - Timing Problems

Hi All

I am using a DM6437 EVM with a custom designed daughterboard. I am trying to communicate with an SPI device on the daughterboard. I initially tried to use the McBSP-as-SPI functionality of the McBSP. After help from members of this forum, I was successful.

However, I have now found out that the SPI device I am communicating with does not comply with its datasheet. I need to communicate at a bus speed of less than 250 kHz, however the lowest I can get the McBSP-as-SPI is approximately 393.125 kHz. For this reason, I am have switched the pins from McBSP to GPIO and am attempting to bit-bash the SPI protocol.

I have written the code for this however I am having a few issues, which I think is releated to the compiler.

It produces a clean clock, data out (MOSI) and slave/chip select signals, however even minor changes to the code causes this to break substantially. Yet changing it back to the original version causes it to work again.

The change involved changing a variable's initialization value from 0x00 to 0x01 - thereby making the clock default be low rather than high.

As you can imagine, bit-bashing the SPI requires strict timing. Is there any way of forcing the compiler to stop executing some of the instructions of the SPI functions in parallel?

Thank you

Regards

Chithambaram

  • Have you taken a look at the assembly generated via the listing file to see if parallel execution is happening?

    I would suggest that you compile this particular file with no optimizations, etc.

    Do you have interrupts enabled during this time?  The reason I ask is you mentioned needing to maintain strict timing, yet if you get an interrupt in the middle of your SPI transaction that might cause havoc.