void SPI_Init()
{
SPI0CFG = 0x40;
SPI0CN = 0x0d;
SPI0CKR = 0x3c;
}
void Port_IO_Init()
{
P0MDOUT = 0xC1;
P2MDOUT = 0x31;
P0SKIP = 0x0C;
XBR0 = 0x03;
XBR1 = 0xC0;
}
unsigned int SPI_WriteByte(unsigned int val)
{
unsigned int ret;
SPI0DAT = val;
while(!SPIF);
SPIF = 0;
ret = SPI0DAT;
return ret;
}
unsigned int SPI_ReadByte(void)
{
unsigned int ret;
SPI0DAT = 0xff; // Dummy write to output serial clock
while (!SPIF); // Wait for the value to be read
SPIF = 0;
ret = SPI0DAT;
return ret;
}
void main(void)
{
EMI0CN=0x01;
PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog
timer
// enable) 1Ø¿′ÃÅ1·
Init_Device();
GPS=0;
// SD_init();
// MMC_SD_WriteSingleBlock(3600);
while(1)
{
PWR=0;
// RUN=0;
// MMC_SD_SendCommand(0x33,0xaa);
// CAM=0;
// GPS=0;
SPI_WriteByte(0xaa);
SPI_WriteByte(0xaa);
}
}
代码如上 连续写相同数据的时候 不会有高电平干扰 对MOSI也设置过开漏 依然有干扰 导致我对SD卡的初始化不正常
请大家分析一下