ALL MY PROGRAM
//-------------------------------------------
// Erase all
//-------------------------------------------
for (c = 0 ; c < NBR_SECTOR ; c++)
{
memset(DataToSend,0,255);
memset(data,0,255);
UARTCount = 0;
count_error = 0;
sprintf(data,"0300000401%c%c%c%c",SectorTable_936[c][0],
SectorTable_936[c][1],
SectorTable_936[c][2],
SectorTable_936[c][3]);
checksum(data);
sprintf(DataToSend,":%s%c%c%c%c",data,checksum_calc[0],checksum_calc[1],13,10);
uart_isp_send_receive((unsigned char *) DataToSend);
while (UARTBuffer[17] != '.') // Ok
{ // gestion erreur à faire
UARTCount = 0;
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_ERASE;
}
}
c = 0;
nbr_line_done = 0;
//-------------------------------------------
// PROGRAM
//-------------------------------------------
do
{
memset(DataToSend,0,255);
memset(data,0,255);
memset(UARTBuffer,0,255);
UARTCount = 0;
PtrData = data;
check_crc = 0;
count_error = 0;
do
{
*PtrData++ = DRIVER[c];
c++;
check_crc++;
}
while ((DRIVER[c] != ':' && DRIVER[c] != 0x00) || check_crc > 64);
sprintf(DataToSend,"%s%c%c",data,13,10);
if (check_crc > 64)
return ERROR_HEX;
do
{
memset(UARTBuffer,0,255);
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_WRITE;
} while((UARTBuffer[check_crc-1] != '.') &&
(UARTBuffer[check_crc] != '.') &&
(UARTBuffer[check_crc + 1] != '.'));
nbr_line_done++;
}
while(nbr_line_done != DRIVER_LINE);
// misc write ---------------------------------------------------
// status bit
memset(DataToSend,0,255);
memset(data,0,255);
UARTCount = 0;
count_error = 0;
sprintf(data,"020000020300");
checksum(data);
sprintf(DataToSend,":%s%c%c%c%c",data,checksum_calc[0],checksum_calc[1],13,10);
do
{
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_STATUS;
} while(UARTBuffer[15] != '.');
//RESET MCU ---------------------------------------------------
memset(DataToSend,0,255);
memset(data,0,255);
sprintf(DataToSend,":00000008F8%c%c",13,10);
uart_isp_send_receive((unsigned char *) DataToSend);
//------------------------------
delay (1000000);
FIO0SET |= BIT18;
delay (1000000);
FIO0CLR |= BIT17;
//------------------------------
// VDD à l'état haut
delay (10000000); //some pcb asks more time before beginning upload
FIO0SET |= BIT17;
return SUCCESS_ISP;
hex file
:04FFF00023001E00CC
:08FFF8000003020000000007F5
:03000000020033C8
:0C00330078FFE4F6D8FD75810702000399
:040020007FA07E86B9
:0F002400EF1F70011E144E600563A00880F222CA
:10000300E4F5A475A5FFF5847585FFF5A0F5806378
:0D001300A0FF12002012002012002080F239
:00000001FE
I send on uart :04FFF00023001E00CC and after :08FFF8000003020000000007F5 ,...
//-------------------------------------------
// Erase all
//-------------------------------------------
for (c = 0 ; c < NBR_SECTOR ; c++)
{
memset(DataToSend,0,255);
memset(data,0,255);
UARTCount = 0;
count_error = 0;
sprintf(data,"0300000401%c%c%c%c",SectorTable_936[c][0],
SectorTable_936[c][1],
SectorTable_936[c][2],
SectorTable_936[c][3]);
checksum(data);
sprintf(DataToSend,":%s%c%c%c%c",data,checksum_calc[0],checksum_calc[1],13,10);
uart_isp_send_receive((unsigned char *) DataToSend);
while (UARTBuffer[17] != '.') // Ok
{ // gestion erreur à faire
UARTCount = 0;
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_ERASE;
}
}
c = 0;
nbr_line_done = 0;
//-------------------------------------------
// PROGRAM
//-------------------------------------------
do
{
memset(DataToSend,0,255);
memset(data,0,255);
memset(UARTBuffer,0,255);
UARTCount = 0;
PtrData = data;
check_crc = 0;
count_error = 0;
do
{
*PtrData++ = DRIVER[c];
c++;
check_crc++;
}
while ((DRIVER[c] != ':' && DRIVER[c] != 0x00) || check_crc > 64);
sprintf(DataToSend,"%s%c%c",data,13,10);
if (check_crc > 64)
return ERROR_HEX;
do
{
memset(UARTBuffer,0,255);
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_WRITE;
} while((UARTBuffer[check_crc-1] != '.') &&
(UARTBuffer[check_crc] != '.') &&
(UARTBuffer[check_crc + 1] != '.'));
nbr_line_done++;
}
while(nbr_line_done != DRIVER_LINE);
// misc write ---------------------------------------------------
// status bit
memset(DataToSend,0,255);
memset(data,0,255);
UARTCount = 0;
count_error = 0;
sprintf(data,"020000020300");
checksum(data);
sprintf(DataToSend,":%s%c%c%c%c",data,checksum_calc[0],checksum_calc[1],13,10);
do
{
uart_isp_send_receive((unsigned char *) DataToSend);
count_error++;
if (count_error > ERROR_ISP)
return ERROR_CRC_STATUS;
} while(UARTBuffer[15] != '.');
//RESET MCU ---------------------------------------------------
memset(DataToSend,0,255);
memset(data,0,255);
sprintf(DataToSend,":00000008F8%c%c",13,10);
uart_isp_send_receive((unsigned char *) DataToSend);
//------------------------------
delay (1000000);
FIO0SET |= BIT18;
delay (1000000);
FIO0CLR |= BIT17;
//------------------------------
// VDD à l'état haut
delay (10000000); //some pcb asks more time before beginning upload
FIO0SET |= BIT17;
return SUCCESS_ISP;
hex file
:04FFF00023001E00CC
:08FFF8000003020000000007F5
:03000000020033C8
:0C00330078FFE4F6D8FD75810702000399
:040020007FA07E86B9
:0F002400EF1F70011E144E600563A00880F222CA
:10000300E4F5A475A5FFF5847585FFF5A0F5806378
:0D001300A0FF12002012002012002080F239
:00000001FE
I send on uart :04FFF00023001E00CC and after :08FFF8000003020000000007F5 ,...