Jump to main content

##

# 2.73.4 NVMCTRL_PageWrite Function

## C

    bool NVMCTRL_PageWrite(uint32_t* data, uint32_t address)

## Summary

Writes one page of data to given NVM address.

## Description

This function will write one page of data to the NVM address specified by the address parameter. The size of the input buffer should be one NVM page. The address should be aligned on a page boundary.

Calling this function will cause the CPU execution to stall, hence blocking execution of any other thread. Execution resumes when the Write operation has completed. For devices with dual flash bank memory, Reading in a bank does not stall the bus when the other bank is being programmed.

If the interrupt operation was enabled and if a callback was registered, then the callback function will be called. The NVMCTRL_IsBusy() function can be used to poll for completion of the operation. The application should ensure that there are no other operations in progress before calling this function. Once the operation is complete, the NVMCTRL_ErrorGet() function can be called to check operation success.

## Precondition

The NVMCTRL_Initialize() function should have been called once. Also validate if NVM controller is ready to accept a new request by calling NVMCTRL_IsBusy().

The Flash page should be in erased state (all bytes should be 0xff) before performing page write.

## Parameters

Param | Description
--- | ---
address | start address of page to be written. This should be aligned on apage boundary.
data | pointer to data buffer. The size of this buffer should be the same asthe page size.

## Returns

Always returns true.

## Example

    // This code snippet shows how the NVMCTRL_PageWrite function is called and
    // how the NVMCTRL_IsBusy function is used to poll for completion.

    NVMCTRL_Initialize();

    // Now write the page.
    NVMCTRL_PageWrite( (uint32_t *)buffer, 0x00030000);

    while(NVMCTRL_IsBusy());

    if(NVMCTRL_ErrorGet() == NVMCTRL_ERROR_NONE)
    {
        // Operation was successful.
    }

## Remarks

None