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

sd_flash_write only once

I'm attaching a function where I use the sd function :

    void edit_speed_ID(uint8_t speed)
    {		
uint32_t value;//, err_code;
value=5  * speed;
while(sd_flash_write(address,(uint32_t *) & value,1)==NRF_ERROR_BUSY);
nrf_delay_ms(1000);
pattern_ID_3();
     }

the problem is that, when I call this function for the first time, it works fine & if I try to call this function its call is done correctly but the sd_flash_write doesn't overwrite the written value for the first time even I don't change the address passed to the sd_flash_write

Parents
  • I use this code:

    static pstorage_handle_t m_p_example_id;
    static pstorage_ntf_cb_t example_cb_handler;
      uint16_t dummy_block = 0;
    uint16_t dummy_size  = 4;
    uint16_t dummy_offset = 0;
    pstorage_handle_t p_block_id;
    
    static void example_pstorage_init()
    {
    uint32_t err_code;         
    pstorage_module_param_t p_example_param;    
    // Setup pstorage with 10blocks of 16byte in each.
    p_example_param.block_size  = 0x04; // recommended to be >= 4 byte
    p_example_param.block_count = 10;
    p_example_param.cb          = example_cb_handler;
    err_code = pstorage_init();
    APP_ERROR_CHECK(err_code);  
    err_code = pstorage_register (&p_example_param, &m_p_example_id);
    APP_ERROR_CHECK(err_code);  
    }
    
    	int main(void)
    	{ 	
    			// Initialize
    			//flash_init();
    			leds_init();
    			timers_init();
    			gpiote_init();
    			ble_stack_init();
    			scheduler_init();    
    			gap_params_init();
    			services_init();
    			advertising_init();
    			conn_params_init();
    			sensor_simulator_init();
    			sec_params_init();
    					example_pstorage_init();
    
    			// Start execution
    			advertising_start();
    			LPCOMP_init();
    			// Enter main loop
    			for (;;)
    			{
    					app_sched_execute();
    					power_manage();
    			}
    	}
    
    void edit_speed_ID(uint8_t speed)
    {	
    	//	uint8_t * value;
    		uint32_t err_code;
    	//	*value =speed;
    		err_code = pstorage_block_identifier_get(&m_p_example_id, dummy_block, &p_block_id);
    		APP_ERROR_CHECK(err_code);
    		err_code = pstorage_store(&p_block_id,&speed, dummy_size, dummy_offset);
    		APP_ERROR_CHECK(err_code);
        }
    

    it caused me not to see the bluetooth device & I'm unable to communicate with it

  • I forgot the problem isn't in the max number of applications, it equals to 20

Reply Children
No Data
Related