Interaction interrupt/delay_ms()

Discuss about beta versions of mikroPascal compiler.
Post Reply
Author
Message
jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Interaction interrupt/delay_ms()

#1 Post by jpc » 07 Jul 2006 16:11

when i tryed to implement a TMR3 interrupt on 4013 i found some problem that looks like interaction between the interrrupt and delay_ms() .
This is a reduced code-example that demonstartes the problem :

Code: Select all

program mysterie;

var mymsecs : longint;


procedure ms_tick_clock; org $22;
begin

    TMR3 := 0;
    IFS0.7 := 0;    // clear flag
    inc(mymsecs);
end;


procedure init; 

begin
  trisb := 0;
  // now enable TMR3 as  tick generator
  mymsecs := 0;
  PR3 :=100;       // interrupt is generated after PR3 TCY
  IPC1.12 := 1;   // Interrupt priority level 1
  TMR3 := 0;
  T3CON := %1000000000000000;  // start Timer3
 
  IEC0.7  := 1;          // enable timer3 interrupts
end;


begin
  init;
  while true do
  begin
    delay_ms(5000);  // should wait for 5 full seconds !
    latb := latb xor 1;
  end;

end.
the LED on PORTB.0 should flash at 5 seconds but seems to flash at a rate related to the PR3 programmed value. I have not yet been able to find any relation between these and found no such problem with other interrupt's until now. Anyone who can explain ? Is this possibly the result of some overenthousiastic optimizer ?

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Interaction interrupt/delay_ms()

#2 Post by zristic » 09 Feb 2007 10:05

I've tried this code. It seems that the interrupt is generated too often and the overhead which executes during the interupt extends the delay.
This is something we should expect to happen, I see nothing wrong with the performance.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#3 Post by jpc » 09 Feb 2007 19:35

glad you found time to look at it , i posted this few days ago BUT , allthough i can undertand now ( as even i have made some progress in those few days) that the provided source will produce perhaps too many interrupts , if i change the value of PR3 to 1000 or 2000 , values that will certainly be beyond the interrupt-overhead time , i would expect the delay to be longer than the programmed time yet it is substantially shorter ! I therefore would like you to look at it again because i still do not understand what happens to the delay_ms

Code: Select all

program mysterie;

var mymsecs : longint;


procedure ms_tick_clock; org $22;
begin

    TMR3 := 0;
    IFS0.7 := 0;    // clear flag
    inc(mymsecs);
end;


procedure init;

begin
  trisb := 0;
  // now enable TMR3 as  tick generator
  mymsecs := 0;
  PR3 :=2000;       // interrupt is generated after PR3 TCY 
  IPC1.12 := 1;   // Interrupt priority level 1
  TMR3 := 0;
  T3CON := %1000000000000000;  // start Timer3

  IEC0.7  := 1;          // enable timer3 interrupts
end;


begin
  init;
  while true do
  begin
    delay_ms(1000);  // should wait for 1 Full second !
    latb := latb xor $FFFF;
  end;

end.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#4 Post by zristic » 12 Feb 2007 09:25

Ok, I will try to debug this with ICD, as soon as I find time. I think ICD will have the most correct answer.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#5 Post by jpc » 17 Feb 2007 13:59

looks like the problem is solved with release 5.0 , this compiles to few ROM-words more , have not seen where they went but now the timing seems correct!

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#6 Post by zristic » 19 Feb 2007 13:18

Yup, behaves well now.

Post Reply

Return to “mikroPascal Beta testing”