Hi,
I try to do the following easy task:
Send four bytes out of McSPI0 channel 0 as fast as possile. SPIEN should stay low while transfering the four bytes.
I want to use the FIFO buffers for transmit as well as for receive.
I have read the TRM a lot of times und I have tried a lot of different things but still it does not work.
What I did so far is the following:
- Setup McSPI0 Module with all the clocks and all the other settings
- Set Single mode of operation
Then I do the following:
1. Load the FIFO with the four bytes
2. Set WCNT to 4
3. Force SPIEN to "0" (that works)
4. Enable channel 0
5. Wait until TXFFE is set
6. Disable channel0
7. Force SPIEN to "1" (works fine)
8. Read four bytes from the receive FIFO
And that is the code:
{ volatile Uint32 dummy; HWREG(SOC_SPI_0_REGS+MCSPI_TX(0))=0x91; HWREG(SOC_SPI_0_REGS+MCSPI_TX(0))=0x92; HWREG(SOC_SPI_0_REGS+MCSPI_TX(0))=0x93; HWREG(SOC_SPI_0_REGS+MCSPI_TX(0))=0x94; HWREG(SOC_SPI_0_REGS+MCSPI_XFERLEVEL)=(4<<MCSPI_XFERLEVEL_WCNT_SHIFT); // Chip Select aktivieren HWREG(SOC_SPI_0_REGS+MCSPI_CHCONF(0))= (HWREG(SOC_SPI_0_REGS+MCSPI_CHCONF(0)) | MCSPI_CH0CONF_FORCE); // Kanal 0 freigeben HWREG(SOC_SPI_0_REGS+MCSPI_CHCTRL(0))=(HWREG(SOC_SPI_0_REGS+MCSPI_CHCTRL(0)) | MCSPI_CH0CTRL_EN_ACTIVE); // Warten, bis Transmit FIFO leer ist while((HWREG(SOC_SPI_0_REGS+MCSPI_CHSTAT(0)) & MCSPI_CH0STAT_TXFFE)==0); // Kanal 0 sperren HWREG(SOC_SPI_0_REGS+MCSPI_CHCTRL(0))=(HWREG(SOC_SPI_0_REGS+MCSPI_CHCTRL(0)) & ~MCSPI_CH0CTRL_EN_ACTIVE); // Chip Select deaktivieren HWREG(SOC_SPI_0_REGS+MCSPI_CHCONF(0))= (HWREG(SOC_SPI_0_REGS+MCSPI_CHCONF(0)) & ~MCSPI_CH0CONF_FORCE); dummy=HWREG(SOC_SPI_0_REGS+MCSPI_RX(0)); dummy=HWREG(SOC_SPI_0_REGS+MCSPI_RX(0)); dummy=HWREG(SOC_SPI_0_REGS+MCSPI_RX(0)); dummy=HWREG(SOC_SPI_0_REGS+MCSPI_RX(0)); }
Result: SPIEN gets low for about a 1us and then high again. But no SPICLK and no data output. The SPI works without the FIFO so there is nothing wrong with the outputs.
Can a TI AM335x McSPI0 expert show me how to do it?
Thanks and best regards,
Patrick