I have some questions about sd_flash_write function:
Will sd_flash_write() evaluates if the input value is 0xFF so that it won't need to perform an unnecessary write?
If there is no 0xFF evaluation, would it be faster to write 0xFF than to write other value?
How long would it take to write 256 words at a time using sd_flash_write() function? Would it cause any great side effect? How about the erase time (1 page of 256 words)?
I'm using SD s110 v7.0.0 on nrf51822 chip.
Thank you for any help!
No, I don't think we have that check in our code in the softdevice.
I don't have the exact amount of time for writing 0xFF, what we have is the maximum timing , which is 46.3us for writing a 32bit word from flash.
You would need to consider the blocking time by the softdevice's radio activity. So it will be 256x46.3 + blocking time. The blocking time is depend on the number of BLE packets have to be transmitted, and if there is any other activity that has higher priority that the flash operation.
The erase time is also defined in the spec, which is 22.3ms. But the erase command also have to be scheduled and the scheduler is dependent on the BLE activity.
You should implement a check for the flash call back event (NRF_EVT_FLASH_OPERATION_ERROR, NRF_EVT_FLASH_OPERATION_SUCCESS) in the system event instead of rely on the timing.
So the max time to write a page would be around 11.8ms which is smaller than erase time. Not a big deal for my app, I guess. Anyway, thank you Hung!
@chd: You are welcome. If the answer answered your question, please mark it as correct.
"You should implement a check for the flash call back event (NRF_EVT_FLASH_OPERATION_ERROR, NRF_EVT_FLASH_OPERATION_SUCCESS) in the system event instead of rely on the timing."
I would like to implement this but don't know how...do you know of any examples? I actually haven't found any examples using sd_flash_write at all.
This is a 3 years old case, please create a new case. We suggest you to use fstorage, and fds instead of accessing the softdevice flash API directly. Here is some examples.