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

Write byte

Hi,

How can i write one byte to specific memory address with sd_flash_write()

Thanks

  • /**@brief Flash Write
     *
     * Commands to write a buffer to flash
     *
     * This call initiates the flash access command, and its completion will be communicated to the
     * application with exactly one of the following events:
     *      - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
     *      - NRF_EVT_FLASH_OPERATION_ERROR   - The command could not be started.
     *
     * @note
     *      - This call takes control over the radio and the CPU during flash erase and write to make sure that
     *        they will not interfere with the flash access. This means that all interrupts will be blocked
     *        for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
     *        and the command parameters).
     *
     *
     * @param[in]  p_dst Pointer to start of flash location to be written.
     * @param[in]  p_src Pointer to buffer with data to be written
     * @param[in]  size  Number of 32-bit words to write. Maximum size is 256 32bit words.
     *
     * @retval ::NRF_ERROR_INVALID_ADDR   Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
     * @retval ::NRF_ERROR_BUSY           The previous command has not yet completed.
     * @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or more than 256 words.
     * @retval ::NRF_ERROR_FORBIDDEN      Tried to write to or read from protected location.
     * @retval ::NRF_SUCCESS              The command was accepted.
     */
    SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
    
  • This is a word Write function. I need a byte write

  • The byte you want to write is 0xBB. To write to a specific byte use: 0xFFFFFFBB, 0xFFFFBBFF, 0xFFBBFFFF, 0xBBFFFFFF. You can write to each byte once(if you don't exploit it), between each flash page erase.

Related