This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FDS - nRF52833. Unable to write less than 32 bits word.

Hi, 

I am learning how to write and read from flash memory on nRF52833 dev board for a BLE application.

I followed the heart rate example as shown in https://devzone.nordicsemi.com/f/nordic-q-a/32208/what-should-i-start-in-order-to-use-the-maximum-memory-space-in-fstorage

If I try to write an uint_8 data I get the error FDS_ERR_UNALIGNED_ADDR. Only 32 bits works ok. 

could you help me understand why please?

Many thanks

Please find attached the fds write function I am using. 

static ret_code_t fds_test_write(void)
{
		
		static uint32_t const m_deadbeef[2] = {1,2};
		//static float const m_deadbeef[2] = {0.1, 2256.5};
		fds_record_t        record;
		fds_record_desc_t   record_desc;

		// Set up data.
		
		// Set up record.
		record.file_id              = FILE_ID_FDS_TEST;
		record.key                  = REC_KEY_FDS_TEST;
		record.data.p_data       = &m_deadbeef;
		//record.data.length_words   = sizeof(m_deadbeef)/sizeof(uint16_t);
		record.data.length_words   = sizeof(m_deadbeef)/sizeof(uint32_t);
                NRF_LOG_INFO("Length = %d \r\n",record.data.length_words);
				
		ret_code_t ret = fds_record_write(&record_desc, &record);
		if (ret != NRF_SUCCESS)
		{
				return ret;
		}
		 NRF_LOG_INFO("Writing Record ID = %d \r\n",record_desc.record_id);
		return NRF_SUCCESS;
}

Parents
  • //static float const m_deadbeef[2] = {0.1, 2256.5}; float type is 4 bytes equal to 32 bits. So I think it's okay in your case. However, the original flash type are 32 bits in Nordic NRF52 or 51 series. So you should follow the rule. By the way, in your case is used the float type. But I think that you have better to convert the data pre-process. For example 2256.5 = 225650 * 10e-2,. Because the data type maybe happen the mistake when you convert float to uint32_t and so on.

     Henry

  • Hi, thanks for your reply.

    Sorry I am not sure I understand. 

    My issue is: I tried the fds_write from here FDS example.

    This example was made based on the heart rate ble example. I tested this fds function in the ble_app_hrs example (from SDK 17.0.2). All worked as expected. 

    Only when I tried to use the same fds_write in my ble application, I get the unaligned address error. 

    Both ble_app_hrs and my application are using the soft device s140. 

    I don't know why I am getting this error. 

    Thanks for your help

  • I get an invalid param with your setting.

    try using 

    record.data.length_words   = (sizeof(m_deadbeef) + 3)/(sizeof(uint32_t)); to see if the alignment is correct. And make sure if the error you get after this is still the unaligned addr?

Reply Children
No Data
Related