求助!S3C2440的SPI驱动为什么读回来的数据都是0xff?
void SPI_InitialGPIO()
{
rGPECON |= 2<<22|2<<24|2<<26;//配置SPI0 GPE端口的GPE11 GPE12 GPE13 分别为MISO MOSI SPICLK
//rGPGCON |= 3<<4;//配置GPG端口的GPG2 为nss0
//rGPEUP &=~(0x3800);
rGPEUP |=(1<<11)|(1<<12)|(1<<13);//配置上拉
rGPGUP |=0x4;//GPG2上拉禁止
rGPGCON=rGPGCON & (~(3<<4)) | (1<<4);
rGPGDAT|=0x4;
rGPFCON = 0x1000;
rGPFUP=0xb0;
//rGPFDAT |= (6<<0);
//rGPBUP &= ~(1<<1);
}
//void SPI0_Interrupt_Init()
//{
//rINTMSK &=~(1<<22);
//pISR_SPI0 = (U32)SPI0_ISR;
//}
void SPI_Mode()
{
// ClearPending(BIT_SPI0);//清除中断挂起
//配置寄存器
rSPPRE0=0x4;//SPICLK=5M
rSPCON0=(0<<5)|(1<<4)|(1<<3)|(1<<2)|(0<<1)|(0<<0); //中断方式
//rSPPIN0=(0<<2)|(1<<1)|(0<<0);
//rGPGDAT &= 0XFFFB;
}
unsigned char SPIReadByte(void)
{
unsigned char SpiRx;
// ClearPending(BIT_SPI0);
rGPGDAT &= ~(1<<2);
while(!(rSPSTA0&0x1));
SpiRx=rSPRDAT0;
while(!(rSPSTA0&0x1));
rGPGDAT |= (1<<2);
return SpiRx;
}
void SPIWriteByte(unsigned char SPIData)
{
//ClearPending(BIT_SPI0);
rGPGDAT &= ~(1<<3);
while(!(rSPSTA0&0x1));
rSPTDAT0=SPIData;
while(!(rSPSTA0&0x1));
rGPGDAT |= (1<<3);
}
我读取的数据也都是0xff,但是短接输入输出口的话,能正确接收数据,不知道问题出现在哪里
有知道的麻烦相互联系下!我qq526861258
小编问题解决了吗?