LM3S SSI读写CAT93C46,总是读到0.
// Enables a peripheral SSI0
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
// Configures pin(s) for use by the SSI peripheral
// PA2 SSI0CLK(SSCK) PA4 SSI0RX(MISO) PA5 SSI0TX(MOSI)
GPIOPinTypeSSI(GPIO_PORTA_BASE,
(GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5));
// Configure the SSI, 1MHZ
SSIConfigSetExpClk(SSI0_BASE, // Base
//SysCtlClockGet()/4, // SSIClk
20000000, // 5MHZ
SSI_FRF_MOTO_MODE_0, // Protocol
SSI_MODE_MASTER, // Mode
1000000, // BitRate
8 // DataWidth
);
// Enables the synchronous serial interface
SSIEnable(SSI0_BASE);
// CAT93C46
CS_EE = 1;
// if Transmit FIFO is empty
do
{
SSI0Status = SSIIntStatus(SSI0_BASE, 0);
}
while((SSI0Status & 0x03) == 0x02);
// Puts a data element into the SSI transmit FIFO
// Write Enable Instruction for CAT93C46
SSIDataPut(SSI0_BASE, 0x98);
SSIDataPut(SSI0_BASE, 0x41);
SSIDataPut(SSI0_BASE, 0x55);
// if Transmit FIFO is empty
do
{
SSI0Status = SSIIntStatus(SSI0_BASE, 0);
}
while((SSI0Status & 0x03) == 0x02);
// Gets a data element from the SSI receive FIFO.
SSIDataPut(SSI0_BASE, 0x81);
SSIDataGet(SSI0_BASE, pulData++);
CS_EE = 0;
是什么原因啊?
此帖出自
小平头技术问答
一周热门 更多>