Device : nrf52840
Platform : baremetal
Peripherals in use :
Softdevice
FDS
SAADC
RTC
I am using FDS Library to Write Data whenever an event is generated (for simulation i have used a timer to trigger write event at every 1s or 100ms).
Non-Frequent FDS Write operations works without any issues but whenever there are sequential writes (10-15 times in a row , non-blocking) , FDS Write Fails.
But when I disable ble (comment out the BLE initialization) it works without any issues.
1) Case 1 : Dispatch Model --> APP_SCH
FDS write fails every time
2) case 2 : dispatch model --> Interrupt
FDS Write works as long as there is no active BLE connection.
How do I approach to fix this issue, I have tried changing all the configs of FDS as well as softdevice. i found out about the dispatch model making it work by trial and error.
How does the soft device affect the FDS operations.
#ifndef FDS_ENABLED #define FDS_ENABLED 1 #endif #ifndef FDS_VIRTUAL_PAGES #define FDS_VIRTUAL_PAGES 16 #endif #ifndef FDS_VIRTUAL_PAGE_SIZE #define FDS_VIRTUAL_PAGE_SIZE 1024 #endif #ifndef FDS_VIRTUAL_PAGES_RESERVED #define FDS_VIRTUAL_PAGES_RESERVED 0 #endif #ifndef FDS_BACKEND #define FDS_BACKEND 2 #endif #ifndef FDS_OP_QUEUE_SIZE #define FDS_OP_QUEUE_SIZE 4 #endif #ifndef FDS_CRC_CHECK_ON_READ #define FDS_CRC_CHECK_ON_READ 1 #endif #ifndef FDS_CRC_CHECK_ON_WRITE #define FDS_CRC_CHECK_ON_WRITE 0 #endif #ifndef FDS_MAX_USERS #define FDS_MAX_USERS 5 #endif
#define RECORDS_FDS_FILE ( 0x3000 )
#define RECORDS_START (0x3001)
void InitializeRecordsInFDS( void )
{
for ( int i = 0; i < MAX_RECORDS; i++ )
{
Record_FDS[ i ].file_id = RECORDS_FDS_FILE;
Record_FDS[ i ].key = RECORDS_START + i;
Record_FDS[ i ].data.p_data = &Records; //// This structure is 20 Bytes in size
Record_FDS[ i ].data.length_words = sizeof( Records) / sizeof( uint32_t );
}
}
/// The function i am using to write FDS data.
static pu_status_t RecordFindAndUpdate( fds_record_t Record_to_Update )
{
pu_status_t status = PU_SUCCESS;
fds_record_desc_t desc = { 0 };
fds_find_token_t tok = { 0 };
status = fds_record_find( Record_to_Update.file_id, Record_to_Update.key, &desc, &tok );
if ( status == PU_SUCCESS )
{
/**< Open the record and read its contents. */
status = fds_record_update( &desc, &Record_to_Update );
if ( status )
{
PU_DBG( PU_LVL_ERR, "FDS Record Update Failed : %x", status );
}
}
else
{
status = fds_record_write( &desc, &Record_to_Update );
if ( status )
{
PU_DBG( PU_LVL_ERR, "Failed to write fds record : %x", status );
}
}
return status;
}