/Designs/Measuring_instruments/AWS01A/SW/PIC16F887/bootloader887/bloader.c
9,7 → 9,7
echo uf > /dev/ttyUSB$1
ascii-xfr -s -v -l 100 ./bltest.hex > /dev/ttyUSB$1
Or add "uf\n\r" and add some dummy characters at end or begin of each line (for 100 ms delay) and use:
Or add "uf\n\r" and add some dummy characters at the end or begin of each line (for 100 ms delay) and use:
cp ./bltest.hex > /dev/ttyUSB0
For adding characters you can use this:
16,6 → 16,10
sed -i 's/^/pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp/' ./bltest.hex
sed -i 1i"uf" ./bltest.hex
Windows script:
echo uf > com1
ping 1.1.1.1 -n 1 -w 100 > nul
FOR /F "tokens=1*" %%i in (bltest.hex) do @echo %%i > com1 & ping 1.1.1.1 -n 1 -w 100 > nul
*/
 
#define ID "$Id$"
111,7 → 115,7
{
if(Condition)
{
putchar('E');
putchar('e');
putchar(ErrorCode+'0');
reset_cpu();
}
158,9 → 162,9
} data;
 
disable_interrupts(GLOBAL);
/*
 
putchar('@'); //Start Erase
 
/*
//Erase program memory is not necessary.
{
int8 i;
192,15 → 196,15
putc(buffer[buffidx]);
} while ( (buffer[buffidx++] != '\r') && (buffidx < BUFFER_LEN_LOD) );
assert(buffidx == BUFFER_LEN_LOD, ERR_BUFFER_OVERRUN); // Error 1 - Buffer Overrun
buffidx--;
//---WDT
restart_wdt();
 
checksum = 0; // Sum the bytes to find the check sum value
for (i=0; i<(buffidx); i+=2)
for (i=0; i<(buffidx-3); i+=2)
{
checksum += atoi_b16 (&buffer[i]);
//!!! printf(".%x",checksum);
}
assert(checksum != 0, ERR_CHECKSUM); // Error 2 - Bad CheckSum
 
230,8 → 234,8
for (i=0,next_addr=addr;i<8;i++)
data.i16[i]=read_program_eeprom(next_addr++);
// Loops through all of the data and stores it in data
// The last 2 bytes are the check sum, hence buffidx-2
for (i=8,dataidx=0; i < (buffidx-2); i += 2)
// The last 2 bytes are the check sum, hence buffidx-4
for (i=8,dataidx=0; i < (buffidx-5); i += 2)
data.i8[dataidx++]=atoi_b16(&buffer[i]);
 
if (addr == 0)
242,7 → 246,7
putchar('%');
}
else
if ( (addr > 7) && (addr <= (LOADER_RESERVED-16)) ) // Do not overwrite BootLoader
if ( (addr >= FLASH_BLOCK_SIZE) && (addr <= (LOADER_RESERVED-16)) ) // Do not overwrite BootLoader
{
// Write program
write_program_memory(addr, &data.i8[0], 16); // It works only with 16 !!!