PDA

View Full Version : DT Instant Interrupt and Bootloader



mikebar
- 22nd September 2014, 04:06
Good morning,
I'm facing a problem using DT instant interrupts and a bootloader I've wrote by myself using PBP.
The chip I'm using is a 18F4685 and the bootloader is located at the bottom of the memory map, about 0x17620.

I'm going to the bootloader section using a @ goto 0x17620 from the main program.
The problem is that the bootloader keep resetting the chip. I suppose because there is still some interrupt vector mapped because of the use of the DT instant interrupts.

If I move in the other way round, meaning the bootloader on the top and the main program at 0x00B00, everything SEEMS to works as expected: bootloader correctly do the job, the main program too.... BUT DT instant interrupts does not fire anymore.
Probably because at location 0x0008 there is something else, related to the code of the bootloader...

So, the question is:
How to use the DT instant interrupts into the main program, once the main program has been relocated by the directive RESET_ORG?
OR
How to keep the main program on the top of the memory (so the DT interrupts are happy) but preventing them to destroy the path of the bootloader? Can I disable the instant interrupts in the bootloader code?

P.S. The instant interrupts I've enabled are 2: TMR1_INT (every 100ms) and RX_INT.

Best regards, and thank in advance.

Mike.

pedja089
- 22nd September 2014, 09:58
You must disable int before entering bootloader. And to exit from bootloader just execute @ RESET, and you are back on ORG 0, and your main program will setup interrupts again, same way as it setup when device is power on.
Just keep in mind that you have some data in RAM from bootloader, so putting CLEAR in your main program is good idea.

mikebar
- 23rd September 2014, 06:00
Hi pedja089,
I did the whole process EXACTLY as you described.
The things I've missed was to disable the interrupt before go to the bootloader.
Probably, the reason why I did not disabled it, is because I thought that since the "@ goto xxxx" happen BEFORE any "@ INT_ENABLE TMR1_INT", this was enough to avoid the interrupt handler.
Seems that is needed to call "@ INT_DISABLE TMR1_INT" even if is not specifically enabled before. Doing that... IT WORKS!
Thank you.

So, here is the trick:


READ 836,x
if x = 1 then 'There is a firmware update available
SEROUT2 PORTD.4,6,[13,10,"Update process start...",13,10]
@ INT_DISABLE TMR1_INT
@ INT_DISABLE RX_INT
INTCON.7 = 0 'Disable Global Interrupt
INTCON.6 = 0
PIE1.5 = 0 'Disable USART RX Interrupt
T1CON.0 = 0 'Disable Timer1
@ goto 0x17680 'This is where my bootloader start
endif


Thank you again for the suggestions.

pedja089
- 23rd September 2014, 08:26
I'm glad that I could help.
Also keep in mind that when you enter bootloader your registers are not in reset state. So I always disable interrupt and timers in bootloader.