Line 1... |
Line 1... |
1 |
/**** BootLoader for PIC16F887 |
1 |
/**** BootLoader for PIC16F887 |
2 |
|
2 |
|
3 |
After Reset PIC run this script with number of ttyUSBn: |
- |
|
4 |
echo uf > /dev/ttyUSB$1 |
- |
|
5 |
sleep 5 |
3 |
Ussage: |
6 |
ascii-xfr -s -v -l 100 ./bltest.hex > /dev/ttyUSB$1 |
4 |
ascii-xfr -s -v -l 100 ./bltest.hex > /dev/ttyUSB$1 |
- |
|
5 |
|
- |
|
6 |
Add "uf\n\r" to the first line of .HEX . |
7 |
*/ |
7 |
*/ |
8 |
|
8 |
|
9 |
#define ID "$Id: bloader.c 2809 2013-03-10 06:31:00Z kakl $" |
9 |
#define ID "$Id: bloader.c 2810 2013-03-10 06:57:44Z kakl $" |
10 |
|
10 |
|
11 |
#CASE // Case sensitive compiler |
11 |
#CASE // Case sensitive compiler |
12 |
|
12 |
|
13 |
#define FLASH_BLOCK_SIZE getenv("FLASH_ERASE_SIZE")/2 // Minimal length of Flash Block Size |
13 |
#define FLASH_BLOCK_SIZE getenv("FLASH_ERASE_SIZE")/2 // Minimal length of Flash Block Size |
14 |
#define RESERVED_BLOCKS 53 // Number of reserved flash blocks for BootLoader |
14 |
#define RESERVED_BLOCKS 53 // Number of reserved flash blocks for BootLoader |
Line 149... |
Line 149... |
149 |
int8 i8[16]; |
149 |
int8 i8[16]; |
150 |
int16 i16[8]; |
150 |
int16 i16[8]; |
151 |
} data; |
151 |
} data; |
152 |
|
152 |
|
153 |
disable_interrupts(GLOBAL); |
153 |
disable_interrupts(GLOBAL); |
- |
|
154 |
/* |
154 |
putchar('@'); //Start Erase |
155 |
putchar('@'); //Start Erase |
155 |
|
156 |
|
156 |
//Erase program. Do not erase "jump to main" and BootLoader. |
157 |
//Erase program memory is not necessary. |
157 |
{ |
158 |
{ |
158 |
int8 i; |
159 |
int8 i; |
159 |
for(i=0;i<32;i++)buffer[i]=0xFF; |
160 |
for(i=0;i<32;i++)buffer[i]=0xFF; |
160 |
} |
161 |
} |
161 |
for(addr=FLASH_BLOCK_SIZE;addr<LOADER_RESERVED+FLASH_BLOCK_SIZE;addr+=FLASH_BLOCK_SIZE) |
162 |
for(addr=FLASH_BLOCK_SIZE;addr<LOADER_RESERVED+FLASH_BLOCK_SIZE;addr+=FLASH_BLOCK_SIZE) |
162 |
{ |
163 |
{ |
163 |
write_program_memory(addr, &buffer[0], 32); |
164 |
write_program_memory(addr, &buffer[0], 32); |
164 |
putchar('.'); |
165 |
putchar('.'); |
165 |
restart_wdt(); |
166 |
restart_wdt(); |
166 |
} |
167 |
} |
167 |
|
168 |
*/ |
168 |
putchar('!'); //Erase completed |
169 |
putchar('!'); //Erase completed |
169 |
|
170 |
|
170 |
//---WDT |
171 |
//---WDT |
171 |
while(!kbhit()) restart_wdt(); //Wait for HEX |
172 |
while(!kbhit()) restart_wdt(); //Wait for HEX |
172 |
putc('\r'); putc('\n'); |
173 |
putc('\r'); putc('\n'); |