PDA

View Full Version : Unusual Interrupts Application Problem



Joe Rocci
- 7th May 2009, 20:44
I have an application that has a home-grown bootloader which loads a PBP application program. The bootloader needs to be remotely invocable even if the PBP program is defunct or doesn't exist. We implemented this by providing a "long break" detection mechanism. The idea is, if the remote host needs to reload the PIC but the PBP program is kaput, it sends a long break character over the serial link ("Long break" = > 0.5 second space condition). When the long break is received, a "secret handshake" is exchanged by the interrupt handler, and then the bootloader begins to run.

The long break is detected by connecting the Timer1 T1G (timer1 gate) line to the Rxd line. If the Rxd line goes low for more than about .5 second, Timer1 overflows, generates an interrupt, and starts the process.

My problem is in how to implement the interrupt handler in the bootloader. We have to assume that the PBP program might be crashed or non-existant, so the long break interrupt process has to run without any support code in the PBP application. Furthermore, if a spurious break occurs but the handshake doesn't work out, control should be passed back to the PBP program. This means that my self-contained bootloader interrupt handler has to preserve enough of the PBP program's state so that it can return if it's possible to return.

I've studied Darrel's "Instant Interupts" code, but it seems that this requires supporting code in PBP, which might not be there.

Can anyone help??

Joe

Darrel Taylor
- 7th May 2009, 22:02
Is the bootloader written in ASM?

The only reason to save the state of PBP's system variables is if the interrupt handler will be using any of the same RAM locations.
If the bootloader is all ASM, then any variables it needs can be placed at the "End" of RAM so they don't interfere with PBP. Then you can very easily just return (retfie) to the PBP program. (after restoring "context"). As long as none of the system vars were changed, PBP will continue from where it left off.

Your approach makes it so that the PBP program itself will not be able to use interrupts, including ON INTERRUPT. It would be possible to have the bootloader pass the interrupt to the PBP program, but it won't be too easy. Hopefully, you won't need interrupts in the PBP program.
<br>

Joe Rocci
- 8th May 2009, 11:55
Darrrel

Thanks for the reply.

Yes, my interrupt handler is in assembler.

I thought about putting the interrupt variables at the end of ram, but how can I protect them from getting overwritten by the PBP program if it gets that large?

Also, I'd like to use interrupts in my PBP program, possibly for another timer and for the UART. It's not necessary to be able to do it through ON INTERRUPT though. We can put in more assembler code, either in the interrupt handler or in the PBP program, as necessary.

More suggestions appreciated.

Joe