CTRDG_Read

# CTRDG_WriteAgbFlashSector

## C Specification

      #include <nitro/ctrdg.h>

      u16 CTRDG_WriteAgbFlashSector(u16 sec_num, u8* src);

      Corresponding AGB function: u16 (*ProgramFlashSector)(u16 secNo,u8 *src)

## Arguments

sec_num | The destination flash sector number.
src | Writes the source address.

## Return Values

Returns 0 if the write succeeds. Returns a non-zero value if it fails.

## Description

This function writes one sector (4 Kbytes) of data beginning from the address given by `src` into the target sector number. `CTRDG_EraseAgbFlashSector` is called inside this routine and data is written after the sector is erased. This function returns an error if the target sector number is out of range. You can find out how many bytes remain available while this routine is executing by accessing the global variable `flash_remainder`.

The access cycle setting does not need to be set beforehand because it is created inside the function. In addition, the `OS_InitTick` function must be called before this function because clock ticks are used by this function to measure timeouts.

Note: All interrupts are disabled inside this function and the cartridge bus is locked for a set period. In particular, when this function is called, do not use DMA that starts automatically during direct sound and V/H blank synchronization, display synchronization, cartridge request, etc.

Note that the AGB backup device cannot be accessed normally with version IS-NITRO-DEBUGGER 1.66 or earlier.

## See Also

`CTRDG_WriteAndVerifyAgbFlash, CTRDG_WriteAgbFlashSectorAsync, CTRDG_WriteAndVerifyAgbFlashAsync
`

## Revision History

05/25/2006 Added a description that the AGB backup device cannot be accessed normally with version IS-NITRO-DEBUGGER 1.66 or earlier.
04/07/2006 Initial version.

CONFIDENTIAL