Hi,
I am currently working on customizing TI's IPNC software package on DM385 processor and its system consists with Linux and BIOS RTOS.
As I changed hardware module, I had to implement SPI firmware code in BIOS side and I have been stuck here for many weeks so far.
I do not understand why following issue is not working and I may so grateful if you could comment any advices for me.
issus. MCSPI_CH0STAT[TXS] is always full.
although I wrote a value in MCSPI_TX0 register, MCSPI_CH0STAT[TXS] is always full and never becomes empty. I think this is a sign of my value is not input in the register.
My initializing step is
*(volatile UInt32*)(0x48181590) = 0x2; // SPI CLK Enable
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x110) |= (0x1<<1); // MCSPI_SYSCONFIG SOFTRESET
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x10) |= (0x1<<2); // MCSPI_HL_SYSCONFIG IDLEMODE 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x10) &= ~(0x1<<3); //
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x110) |= (0x1<<3); // MCSPI_SYSCONFIG SIDLEMODE 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x110) &= ~(0x1<<4); //
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x110) |= (0x3<<8); // MCSPI_SYSCONFIG CLOCKACTIVITY 3h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<24); // SBPOL 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<13); // TRM 2h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) &= ~(0x1<<12);
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<7) | (0x1<<8) | (0x1<<9); // WL 7h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x128) = 0x1; // McSPI_MODULCTRL
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<6); // EPOL 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<1); // POL 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1); // PHA 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x12C) |= (0x1<<24) // SBPOL 1h
| (0x1<<25) | (0x1<<26) // TCS 3h
| (0x1<<29); //CLKG 1h
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x118) = (0x0); // MCSPI_IRQSTATUS 0h
and after the initialization I called spi write function, which simply is
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x134) = 0x1; // MCSPI_CH0CTRL Channel 0 enable
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x138) = IMX172_WRITE_CMD;
while((*(volatile UInt32*)(SPI0_BASE_ADDR + 0x130))==0) {;} // Wait until empty MCSPI_CH0STAT
*(volatile UInt32*)(SPI0_BASE_ADDR + 0x134) = 0x0; // MCSPI_CH0CTRL Channel 0 disable
With scope, I am not able to detect any signal has been sent through the SPI data line and MCSPI_CH0STAT[TXS] is never changed.
Below 2 tables are parts of datasheet that I was referred to and if you need further information, please let me know.
----------------------------------------Table 21-8. SPI Transmit Mode Initialization-------------------------------------------
Step Register/Bit Field/Programming Model Value
Set transmit mode. MCSPI_CHxCONF[13:12] TRM 0x2
Set the word length. MCSPI_CHxCONF[11:7] WL 0x8
Clock initialization and channel enabling MCSPI_MODULCTRL[2] MS 0x0
MCSPI_CHxCTRL[0] EN 0x1
Channels activated low during active state MCSPI_CHxCONF[6] EPOL 0x1
Clock held high during active state MCSPI_CHxCONF[1] POL 0x0
Data latched on odd-numbered edges of the SPI MCSPI_CHxCONF[0] PHA 0x0
clock
Reset the status bits. MCSPI_IRQSTATUS 0x0
----------------------------------------Table 21-12. Transmit-Only Procedure – Polling Method------------------------------
Step Register/Bit Field/Programming Model Value
Configure the channel according to the mode. See Table 21-8
Start the channel. MCSPI_CHxCTRL[0] EN 0x1
Wait until end of transfer? MCSPI_CHxSTAT[2:1] = 0x2
Stop the channel. MCSPI_CHxCTRL[0] EN 0x0
-------------------------------------------------------------------------------------------------------------------------------------------------
Very grateful for your time to read this issue.
Best regards,
HanGil Kang