Oznog
Active Member
I finally figured out how to use a bootloader with PICC18! Hooray!
OK, I have some questions now. This setup is such that the bootloader will delay startup of the main code until a timer has expired or the serial port receives a character. This looks painful for the product to sit there waiting every time in normal use, but if I reduce the counter to 1/10 sec or so it would be tough to hit the spacebar in Hyperterminal in time.
Also I want to use that same RS232 port for talking to a GPS through the NMEA-0183 serial protocol. By the rules the bootloader uses, it seems that if the GPS were already plugged in and sending data as the PIC is powered up, it would go into bootloading mode upon receipt of the first character, not only failing to execute code but putting it in grave danger of overwriting the program with misinterpreted GPS data.
It occurs to me that the thing to do would be to have the bootloader only respond if it sees "THIS IS A PROGRAM" somewhere in the data stream as it powers up, if it doesn't occur in the first 20 characters immediately, go into normal mode. It is quite unlikely the GPS data will randomly come up with this string of character. The bootloader is in C, I can recode it to do this (and recognize "IS A PROGRAMTHIS" as valid too). But I do not know how to handle the computer side of it (Hyperterm); it seems it will need to continuously loop sending "THIS IS A PROGRAM" until it sees the part respond with a "READY TO PROGRAM" string. This would be something an end-user will need and I'd like it to be supported on a Mac too, so it would need to be a "generic" solution. Is there a scripting language I could use with Hyperterm so I don't have to learn to write a whole damn windows program?
Or should I just send them a .hex file with 10,000x "THIS IS A PROGRAM" before the code, and just say that you must start the "Send Text File" with the part powered down and then power up the part within x seconds so it catches the string? Seems a bit confusing to a non-user, especially if they're fiddling the with baud rate settings.
OK, I have some questions now. This setup is such that the bootloader will delay startup of the main code until a timer has expired or the serial port receives a character. This looks painful for the product to sit there waiting every time in normal use, but if I reduce the counter to 1/10 sec or so it would be tough to hit the spacebar in Hyperterminal in time.
Also I want to use that same RS232 port for talking to a GPS through the NMEA-0183 serial protocol. By the rules the bootloader uses, it seems that if the GPS were already plugged in and sending data as the PIC is powered up, it would go into bootloading mode upon receipt of the first character, not only failing to execute code but putting it in grave danger of overwriting the program with misinterpreted GPS data.
It occurs to me that the thing to do would be to have the bootloader only respond if it sees "THIS IS A PROGRAM" somewhere in the data stream as it powers up, if it doesn't occur in the first 20 characters immediately, go into normal mode. It is quite unlikely the GPS data will randomly come up with this string of character. The bootloader is in C, I can recode it to do this (and recognize "IS A PROGRAMTHIS" as valid too). But I do not know how to handle the computer side of it (Hyperterm); it seems it will need to continuously loop sending "THIS IS A PROGRAM" until it sees the part respond with a "READY TO PROGRAM" string. This would be something an end-user will need and I'd like it to be supported on a Mac too, so it would need to be a "generic" solution. Is there a scripting language I could use with Hyperterm so I don't have to learn to write a whole damn windows program?
Or should I just send them a .hex file with 10,000x "THIS IS A PROGRAM" before the code, and just say that you must start the "Send Text File" with the part powered down and then power up the part within x seconds so it catches the string? Seems a bit confusing to a non-user, especially if they're fiddling the with baud rate settings.