I am developing on the xCORE-200 MC Audio board trying to get persistent flash memory working. I have followed the steps in AN00188 (http://www.xmos.com/support/appnotes/AN00188) and was able to get my application reading from the binary file as per the example but I have not been able to write to this file. I have tried fl_writeData and fl_writeDataPage functions with no luck, yet fl_readData and fl_readDataPage work fine. Below are my functions. What am I missing?
Code: Select all
void app(fl_QSPIPorts &ports, client uart_tx_if uart_tx, client uart_rx_if uart_rx)
{
char config[CONFIG_SIZE];
char read;
readConfig(ports, config, CONFIG_SIZE);
read = config[0];
uart_tx.write(config[0]);
config[0] = read + 1;
writeConfig(ports, config, CONFIG_SIZE);
...
}
int readConfig (fl_QSPIPorts &ports, char *config, char size)
{
// Connect to the QuadSPI device using the quadflash library function fl_connectToDevice.
if(fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec)) != 0)
{
return 1;
}
if(fl_readData(0, size, config) != 0)
{
return 1;
}
// Disconnect from the QuadSPI device.
fl_disconnect();
return 0;
}
int writeConfig (fl_QSPIPorts &ports, char *config, char size)
{
char writeBuffer[PAGE_SIZE];
// Connect to the QuadSPI device using the quadflash library function fl_connectToDevice.
if(fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec)) != 0)
{
return 1;
}
if(fl_writeData(0, size, config, writeBuffer) != 0)
{
return 1;
}
// Disconnect from the QuadSPI device.
fl_disconnect();
return 0;
}
int writeConfigPage (fl_QSPIPorts &ports, char *config, char size)
{
char writeBuffer[PAGE_SIZE];
for(int i = 0; i < PAGE_SIZE; ++i)
{
if(i < size)
{
writeBuffer[i] = config[i];
}
else
{
writeBuffer[i] = 0;
}
}
// Connect to the QuadSPI device using the quadflash library function fl_connectToDevice.
if(fl_connectToDevice(ports, deviceSpecs, sizeof(deviceSpecs)/sizeof(fl_QuadDeviceSpec)) != 0)
{
return 1;
}
if(fl_writeDataPage(0, writeBuffer) != 0)
{
return 1;
}
// Disconnect from the QuadSPI device.
fl_disconnect();
return 0;
}
Daniel