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 high throughput

Other Parts Discussed in Thread: SYSCONFIG

Dear all,

I am working with SPI bus. I already used a lot spidev and it seems to work really good. Now I would like to go ahead and try to set directly registers to use the SPI bus. I decided to short MOSI and MISO to check data and to use the AM335xx as master. I am not working at high frequency.

This is my main settings:

*(data + SPI_SYSCONFIG) |= 0x3;

*(data + SPI_IRQENABLE) = 0x0;

*(data + SPI_SYST)      = 0x80;

*(data + SPI_MODULECTRL) = 0x01;

*(data + SPI_CH1CONF)    = 0x00190FF0;


If a try to have a single write doing:

*(data + SPI_CH1CTRL ) = 0x1;
*(data + SPI_TX1 )     = data_to_sent;
*(data + SPI_CH1CTRL ) = 0x0;


it works as I want: I can read on MISO data sent by MOSI.

When I try to have a loop, such as:

for(i = 0; i < N; i++){

*(data + SPI_CH1CTRL ) = 0x1;
*(data + SPI_TX1 )     = data_to_sent[i];
*(data + SPI_CH1CTRL ) = 0x0;

}

data on MISO are different from data on MOSI; if I try to put a sleep in the for cycle, it works again.

for(i = 0; i < N; i++){

*(data + SPI_CH1CTRL ) = 0x1;
*(data + SPI_TX1 )     = data_to_sent[i];
*(data + SPI_CH1CTRL ) = 0x0;

sleep(1);

}

It seems that, for some reason that I do not understand at all, MISO does not follows MOSI in a for loop without that sleep. Am I missing something (maybe there is a wrong setting on a register or I do not reset something else..)?

Any help is really really appreciate.

Regards.

Alberto