Renesas M16C/6V Manual de usuario Pagina 12

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 18
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 11
FLASHER 5 Manual 12
//
// The following example shows how to calculate the CRC over all bytes
// in a buffer as described above using the CRC_Calc() function
//
unsigned long NumBytes;
unsigned long i;
unsigned char* pBuffer;
unsigned char Fillbyte;
unsigned int CRC;
NumBytes = SUM_OF_ALL_BYTES; // Number of bytes of all selected flash sectors
//
// Create a buffer for all bytes
//
pBuffer = (unsigned char*) malloc(NumBytes);
//
// Initialize the buffer, fill up with the fill bytes
//
if (pBuffer != NULL) {
Fillbyte = FLASHER_FILL_BYTE; // The fill byte set in Flasher options
memset(pBuffer, Fillbyte, NumBytes);
//
// Fill the buffer with data. This has to be done by a function that
// parses the Hexfile and addresses the buffer according the address
// offset which depends on the selected flash sectors
//
ParseFile(pBuffer, NumBytes);
//
// Initialize CRC and calculate CRC over all bytes in the buffer
//
CRC = CRC_Calc(pBuffer, NumBytes);
}
Remarks:
The first byte in the buffer has to be the first byte of the first selected flash sector, regardless the address of
the sector.
For example, if the first selected sector has address 0x3000, the first byte in the buffer (offset 0) is the byte
at address 0x3000 in the target device.
If the hex file addresses only some of the bytes in a flash sector, all the other bytes have to be filled up with
the fill byte.
For example, if the selected flash sector has 4096 bytes, starting from address 0x3000 and the hex-file only
contains data for the first 16 bytes, the whole area from 0x3010 to 0x3FFF has to be filled up with the fill
byte.
All selected sectors are stored in ascending address order without any gap, regardless the start address of
the flash sectors.
For example, if the first sector starts at address 0x3000 and has a total size of 0x1000, the second selected
sector starts at 0x8000 and has a total size of 0x1000, the buffer to hold the data needs a size of 0x2000
bytes.
The first byte from the first sector is stored at offset 0 in the buffer, the first byte of sector 2 is stored at off-
set 0x1000.
Vista de pagina 11
1 2 ... 7 8 9 10 11 12 13 14 15 16 17 18

Comentarios a estos manuales

Sin comentarios