I added below code for changing pin to PTE0~3,
| SIM_PINSEL0 |= SIM_PINSEL_SPI0PS_MASK; | | | // set PTE0~3 as SPI0 |
I'm using below functions.
void SPI_Write(SPI_MemMapPtr base, uint8 u8Write)
{
while (!SPISR_SPTEF(base)); /* sending finish? */
SPI_D_REG(base) = u8Write;
}
uint8 SPI_Read(SPI_MemMapPtr base)
{
while(!SPISR_SPRF(base)); /* read finish? */
return SPI_D_REG(base);
}
I tested simple code like below,
CS0_LOW();
SPI_Write(); // 1 byte write
SPI_Read(); // 1 byte read
CS0_HIGH();
But, problem is write function looks like normal, but read function doesn't work.
when CS goes LOW, only 8 clocks out.
Looks like "SPISR_SPRF(base)", is already set.
How can I solve this problem?