Interrupt Routine not firing

General discussion on mikroPascal PRO for PIC.
Author
Message
philcr
Posts: 24
Joined: 24 Jul 2014 09:37

Re: Interrupt Routine not firing

#16 Post by philcr » 12 Jan 2015 21:04

Guys I gave up with the boot loader and used my pic kit 3 to program all is working as I would expect, many thanks for the time you have spent helping me out.

Kindest Regards

Phil

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Interrupt Routine not firing

#17 Post by janni » 12 Jan 2015 22:26

philcr wrote:39 361 Bad function absolute address 'interrupt[4104]' RealTimeClock.mpas
39 342 There is not enough ROM space interrupt[4104] RealTimeClock.mpas
That's because you probably left main org-ed at 0x1000. Move main after the ISR (keeping OrgAll as it is).

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Interrupt Routine not firing

#18 Post by janni » 12 Jan 2015 22:29

philcr wrote:Guys I gave up with the boot loader and used my pic kit 3 to program all is working as I would expect
I'm glad it's working :) , and you may always reprogram the chip and have the bootloader back.

philcr
Posts: 24
Joined: 24 Jul 2014 09:37

Re: Interrupt Routine not firing

#19 Post by philcr » 12 Jan 2015 23:12

I have tried changing the organisation for main to like 1040 but my program doesn't run. I think I'm just going to persevere with normal programming using the pic kit programmer. It's not as scary as it used to be back in the 90's.

Many thanks again for all your help.

Phil

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Interrupt Routine not firing

#20 Post by janni » 12 Jan 2015 23:54

philcr wrote:I have tried changing the organisation for main to like 1040 but my program doesn't run.
Right, you can't just move the main - bootloader jumps to 0x1000 and expects this to be start of code (what were I thinking :roll: ). Microchip bootloader assumes that addresses are simply shifted and organized just like processor addresses starting at 0x0000 - and some compilers do the shifting automatically when requested. mP however, does not, so one has to do it manually.
What your code is lacking at the moment is the shifted RESET vector, so you need to add a procedure placed at 0x1000 with the sole purpose of jumping to main. The following should do it:

Code: Select all

procedure res_vec; org 0x1000;
 begin
  asm goto _main end;
 end; 

procedure interrupt; org 0x1008;
 begin
  ...
 end; 

BEGIN
  orgall(0x1000);
  { Main program }
Note that that you don't need to place main at any specific address - let compiler do it, as well as replace 'goto _main' with jump to appropriate address.
I think I'm just going to persevere with normal programming using the pic kit programmer. It's not as scary as it used to be back in the 90's.
It sure is easier :) and bootloader may sometimes be limiting. On the other hand, it's good to know how to handle bootloader in case a project needs it.

manu_espagne
Posts: 6
Joined: 22 Feb 2016 14:54

Re: Interrupt Routine not firing

#21 Post by manu_espagne » 17 Jan 2018 18:47

Hello everyone,
I'm trying to use INT0 (RB0) interrupt with a PIC 18F4620 but it don't wake up with a rising edge on RB0
Here is my code
procedure Interrupt;
begin
if INTCON.INT0IF=1 then
begin
PORTC.0:=1;
etat:=etat xor 1;
INTCON.INT0IF:=0;
end;
end;

begin

TRISC:=$00;
TRISB:=$FF;
//PORTB:=$00;
TRISD:=$FF;
indice:=0;
etat:=true;
INTCON.INT0IF:=0;
INTCON.INT0IE:=1;
INTCON.GIE:=1;
INTCON.PEIE:=1;
INTCON2.INTEDG0:=1;


while true do
begin
while indice<8 do
begin
PORTC.indice:=1;
delay_ms(500);
if etat=true then
begin
PORTC.indice:=0;
indice:=indice+1;
end;
end;
indice:=0;
end;
end.

Post Reply

Return to “mikroPascal PRO for PIC General”