Part Number:CC2538
Hello! After resolving a problem with eeprom connection via I2C I'm trying to communicate with serial flash memory via SPI. I've got an example from driverlib (spi_master) and tested it on my board. It works fine when I connect MISO and MOSI together (loopback). I've tried to convert this example in order to work with spi flash sst26vf064ba but unsuccesfully. I see on my scope all needed signals (CS, CLK, MOSI) except MISO and get 0xFF or 0x0 while reading. Here is my code:
//
// Set the clocking to run directly from the external crystal/oscillator.
// (no ext 32k osc, no internal osc)
//
SysCtrlClockSet(false, false, SYS_CTRL_SYSDIV_32MHZ);
//
// Set IO clock to the same as system clock
//
SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ);
//
// The SSI0 peripheral must be enabled for use.
//
SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_SSI0);
//
// Disable SSI function before configuring module
//
SSIDisable(SSI0_BASE);
//
// Set IO clock as SSI clock source
//
SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_PIOSC);
IOCPinConfigPeriphOutput(GPIO_SSI0_BASE, PIN_SCLK0,
IOC_MUX_OUT_SEL_SSI0_CLKOUT);
IOCPinConfigPeriphOutput(GPIO_SSI0_BASE, PIN_CS0,
IOC_MUX_OUT_SEL_SSI0_FSSOUT);
IOCPinConfigPeriphOutput(GPIO_SSI0_BASE, PIN_MOSI0,
IOC_MUX_OUT_SEL_SSI0_TXD);
IOCPinConfigPeriphInput(GPIO_SSI0_BASE, PIN_MISO0,
IOC_SSIRXD_SSI0);
GPIOPinTypeSSI(GPIO_SSI0_BASE, PIN_SCLK0 |
PIN_CS0 | PIN_MISO0 |
PIN_MOSI0);
//
// Configure SSI module to Motorola/Freescale SPI mode 3:
// Polarity = 1, SCK steady state is high
// Phase = 1, Data changed on first and captured on second clock edge
// Word size = 8 bits
//
SSIConfigSetExpClk(SSI0_BASE, SysCtrlIOClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, SysCtrlClockGet()/2, 8);
//
// Enable the SSI0 module.
//
SSIEnable(SSI0_BASE);
//
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk. This is done here
// because the SPI SSI mode is full-duplex, which allows you to send and
// receive at the same time. The SSIDataGetNonBlocking function returns
// "true" when data was returned, and "false" when no data was returned.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
//
uint32_t data =0x0;
while(SSIDataGetNonBlocking(SSI0_BASE, &data))
{
}
int i=0;
while(1)
{
/*SSIDataPut(SSI0_BASE, 0x5);
while(SSIBusy(SSI0_BASE)); */
while(!SSIDataPutNonBlocking(SSI0_BASE, i))
{
}
/*SSIDataGet(SSI0_BASE, &data);
while(SSIBusy(SSI0_BASE));*/
while(SSIDataGetNonBlocking(SSI0_BASE, &data))
{
}
if (data!=0xFF)
{
int a=0;
}
i = (i+1)&0xFFFFF;
}
Does anyone know where is the problem? Please, give some advice.