- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi There,
I notice the WIP always busy non stop. May I know what happened?
here is my code
#define CMD_S25FLXX_WRITE_ENABLE 0x06 /* write Enable */
#define CMD_S25FLXX_READ_STATUS_REG 0x05 /* read Status Register */
#define CMD_S25FLXX_PAGE_PROGRAM 0x02 /* Page Program */
#define ADDRESS_1 12304
static uint8_t buf_data[34] = {0};
int main()
{
uint8_t test_data[7] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07};
S25FLXX_write_data(ADDRESS_1 ,test_data,7);
S25FLXX_wait_ready();
}
/* CHECK CHIP READY*/
void S25FLXX_wait_ready(void)
{
do
{
nrf_delay_ms(10);
buf_cmd[0] = CMD_S25FLXX_READ_STATUS_REG;
/* reset transfer done flag */
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&S25FLXX, buf_cmd, 1, buf_data, 2));
S25FLXX_spi_wait_until_transfer_is_completed();
printf("buf_data:%d\r\n",buf_data[1]);
}
while ((buf_data[1] & S25FLXX_BUSY) == S25FLXX_BUSY);
}
/* WRITE FUNCTION */
uint8_t S25FLXX_write_data(uint32_t address, uint8_t* buf, uint16_t length)
{
if (! S25FLXX_is_busy())
{
uint16_t i;
uint16_t len;
uint8_t offset;
/* Write Enable */
buf_cmd[0] = CMD_S25FLXX_WRITE_ENABLE;
/* reset transfer done flag */
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&S25FLXX, buf_cmd, 1, buf_data, 1));
S25FLXX_spi_wait_until_transfer_is_completed();
/* Page Program */
buf_cmd[0] = CMD_S25FLXX_PAGE_PROGRAM;
buf_cmd[1] = (uint8_t)((address & 0x00FF0000) >> 16);
buf_cmd[2] = (uint8_t)((address & 0x0000FF00) >> 8);
offset = (uint8_t)(address & 0x000000FF);
len = ((S25FLXX_PAGE_SIZE - offset) < length) ? (S25FLXX_PAGE_SIZE - offset) : length;
// len = length;
buf_cmd[3] = offset;
len += 4;
for (i = 4; (i < len); i++)
{
buf_cmd = buf[i-4];
}
/* reset transfer done flag */
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&S25FLXX, buf_cmd, len, buf_data, 1));
S25FLXX_spi_wait_until_transfer_is_completed();
return S25FLXX_OK;
}
else
{
return S25FLXX_BUSY;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have discover its caused by the device's interrupt issue. Therefore we would like to close this topics.