This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Nrf51422 how to use sd_flash_page_erase, sd_flash_write in SD210

Hi, Now I use these fun in ANT SD210 like below:

void MyFlashWrite(ble_ant_csc_t* cscdata) { uint32_t addr; uint32_t patwr[3]; uint32_t pg_size; uint32_t pg_num; patwr[0]=111;//cscdata->cadence_revolution_cnt_tmp; patwr[1]=222; patwr[2]=333;

  pg_size = NRF_FICR->CODEPAGESIZE;
pg_num  = NRF_FICR->CODESIZE - 1;  // Use last page in flash

addr = (pg_size * pg_num);// Start address
  printf("Write Addr: 0x%X \r\n",addr);
sd_flash_page_erase(addr);// Erase page
  sd_flash_write	(	&addr, patwr, 3 );	

}

void MyFlashRead(ble_ant_csc_t* cscdata) { uint32_t *addr; uint32_t pg_data; uint32_t pg_size; uint32_t pg_num;

  pg_size = NRF_FICR->CODEPAGESIZE;
pg_num  = NRF_FICR->CODESIZE - 1;  // Use last page in flash
  printf("pg_size: 0x%X, pg_num: 0x%X\r\n",pg_size,pg_num);

addr = (uint32_t *)(pg_size * pg_num);// Start address
  printf("Read Addr: 0x%X \r\n",addr);
  flash_word_read(addr, &pg_data);
  printf("pg_data: %d \r\n",pg_data);

}

But the data read back always be 0, so I dont know where is the problem. and I dont find any answer in other question, so Does anyone can tell me how to use flash read/write in Ant SD210.

Thanks

Parents
  • Since ANT use the same mechanism as BLE for flash writes while protocol activity, it should work the same way.

    After you do a flash write or read, you should get a system event which are defined in nrf_soc.h

      NRF_EVT_FLASH_OPERATION_SUCCESS,              /**< Event indicating that the ongoing flash operation has completed successfully. */
      NRF_EVT_FLASH_OPERATION_ERROR,                /**< Event indicating that the ongoing flash operation has timed out with an error. */
    

    So you should first check if the flash operation is successful or not

    I am not an expert in ANT, but i know that it is the same mechanism there, so do not use the code directly, i just used it to explain the concept.

Reply
  • Since ANT use the same mechanism as BLE for flash writes while protocol activity, it should work the same way.

    After you do a flash write or read, you should get a system event which are defined in nrf_soc.h

      NRF_EVT_FLASH_OPERATION_SUCCESS,              /**< Event indicating that the ongoing flash operation has completed successfully. */
      NRF_EVT_FLASH_OPERATION_ERROR,                /**< Event indicating that the ongoing flash operation has timed out with an error. */
    

    So you should first check if the flash operation is successful or not

    I am not an expert in ANT, but i know that it is the same mechanism there, so do not use the code directly, i just used it to explain the concept.

Children
No Data
Related