Hi,
I am trying to communicate with the on board EEPROM flash MX66L51235F. I'm just sending RDID command which will give me Manufature's ID and Device ID in return.
Here is the code.
#include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/ssi.h" #include "driverlib/sysctl.h" #include "inc/hw_ssi.h" #include "inc/hw_types.h" void Config_Master(uint32_t); int main() { uint32_t ui32SysClk; static uint32_t dummy[3] = {0}; uint32_t i=0; // define data that you want to receive uint32_t rx_data; // set the system clock to be 25MHz ui32SysClk = SysCtlClockFreqSet(SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ, 25000000); //Configure Master Module and system Parameters. Config_Master(ui32SysClk); // Issue RDID command 9F SSIDataPut(SSI3_BASE,0x9F); // Read ID SSIDataPut(SSI3_BASE,0x00); SSIDataGet(SSI3_BASE,&dummy[0]); SSIDataPut(SSI3_BASE,0x00); SSIDataGet(SSI3_BASE,&dummy[1]); SSIDataPut(SSI3_BASE,0x00); SSIDataGet(SSI3_BASE,&dummy[2]); for (i=0; i<2000; i++){} while(1); } void Config_Master(uint32_t clk) { uint32_t SysClk = clk; // Enable system peripheral SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); // Enable GPIO Ports pin types as SPI GPIOPinTypeSSI(GPIO_PORTQ_BASE,(GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2)); GPIOPinTypeSSI(GPIO_PORTF_BASE,GPIO_PIN_0); // Configure GPIO pins GPIOPinConfigure(GPIO_PQ0_SSI3CLK); GPIOPinConfigure(GPIO_PQ1_SSI3FSS); GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0); GPIOPinConfigure(GPIO_PF0_SSI3XDAT1); // Provide colck to the module. SSIConfigSetExpClk(SSI3_BASE, SysClk, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 8); SSIAdvModeSet(SSI3_BASE,SSI_ADV_MODE_LEGACY); SSIAdvFrameHoldEnable(SSI3_BASE); // SSI Module 0 Enable // SysCtlPeripheralReset(SYSCTL_PERIPH_SSI3); SSIEnable(SSI3_BASE); }
Problem:
1. If I use following code then I'm not getting any data. it gets stuck in while busy loop. According to my understanding we have to wait for the untill the transmission is finished. But strange thing is that if i'm not using SSIbusy() then I'm getting the data.
SSIDataPut(SSI3_BASE,0x9F); while(SSIBusy(SSI3_BASE)); SSIDataGet(SSI3_BASE,&dummy[0]);
2. Slave will send me total 3 bytes in return. and I'm reading those bytes in dummy[ ]. Without using the SSIbusy its working fine, but sometimes it misses first byte.
3. I dont know how to flush the receive FIFO. at the very beginning I will receive some garbage and then I have to read the data sent by slave. can anyone tell me how to reset the Rx FIFO?
Thanks