Strange problem

General discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
sgoum
Posts: 11
Joined: 21 Oct 2012 07:50

Strange problem

#1 Post by sgoum » 16 Nov 2012 13:03

Code: Select all

procedure int2_interrupt(); iv IVT_EXTERNAL_2; ilevel 4; ics ICS_AUTO;
var
tmp_time:word;
begin
  if  time_speed>0 then
  begin
       speed := (36*perimeter) / time_speed; // Km/h
       time_speed := 0;
   end;
  INT2IF_bit := 0;                    // Reset INT2 flag
end;

procedure Timer1Int(); iv IVT_TIMER_1; ilevel 7; ics ICS_SRS;
begin
  inc(time_speed);
  inc(time_Delay1);
  T1IF_bit := 0;             // Clear T1IF
end;
I have this interrupt routines.
When I try to generate an external interrupt on RE9 the program stops to execute. Sometimes even the screen crashes and fills with color lines.
When I comment the following line everything works ok

Code: Select all

//speed := (36*perimeter) / time_speed; // Km/h
What am I doing wrong?

I have a PIC32MX460F512L board

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

Re: Strange problem

#2 Post by LGR » 17 Nov 2012 20:30

Using '/' forces floating point arithmetic. Is that what you want to do? Floating point in an interrupt routine may be too much for a fast interrupt to handle.
If you know what you're doing, you're not learning anything.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Strange problem

#3 Post by filip » 19 Nov 2012 11:39

Hi,

Could you comment the line that does the floating math and see if you have the same issue ?

Regards,
Filip.

sgoum
Posts: 11
Joined: 21 Oct 2012 07:50

Re: Strange problem

#4 Post by sgoum » 24 Nov 2012 09:55

I think its the math line.
I solved it using a boolean expression in the interrupt routine and do the math on the main loop

Post Reply

Return to “mikroPascal PRO for PIC32 General”