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
  • Hi, I dont see the on_sys_evt in ANT->bsc_tx->cadence example. and the flash does not have read fun, I just saw the fun in nRF51 Series > SoftDevices > S210 SoftDevice > S210 SoftDevice API > S210 SoftDevice v5.0.0 > API Reference > SoC Library API There are

    1.uint32_t sd_flash_page_erase	(uint32_t 	page_number)
    2.uint32_t sd_flash_protect	(uint32_t 	protenset0, uint32_t 	protenset1 )
    3.uint32_t sd_flash_write	(uint32_t *const 	p_dst, uint32_t const *const 	p_src, uint32_t 	size)
    

    that's all.

    So does any one of your company can tell me where has a document or example. Because I just 3 words need save before MCU into sleep.

    Thanks.

Reply
  • Hi, I dont see the on_sys_evt in ANT->bsc_tx->cadence example. and the flash does not have read fun, I just saw the fun in nRF51 Series > SoftDevices > S210 SoftDevice > S210 SoftDevice API > S210 SoftDevice v5.0.0 > API Reference > SoC Library API There are

    1.uint32_t sd_flash_page_erase	(uint32_t 	page_number)
    2.uint32_t sd_flash_protect	(uint32_t 	protenset0, uint32_t 	protenset1 )
    3.uint32_t sd_flash_write	(uint32_t *const 	p_dst, uint32_t const *const 	p_src, uint32_t 	size)
    

    that's all.

    So does any one of your company can tell me where has a document or example. Because I just 3 words need save before MCU into sleep.

    Thanks.

Children
No Data
Related