MikroC debug problem

Discussion in 'Programmer's Corner' started by blackmamba, Jan 8, 2010.

  1. blackmamba

    Thread Starter New Member

    Dec 4, 2009
    16
    0
    Hello. I am having a problem with this right now. Using mikroc, while debugging, I am seeing that the interrupt condition is being met, but the program is not entering the interrupt function. What could be causing this?
     
  2. S_lannan

    Active Member

    Jun 20, 2007
    247
    2
    i don't think their simulator 'simulates' isrs. try proteus perhaps...
     
  3. blackmamba

    Thread Starter New Member

    Dec 4, 2009
    16
    0
    The OP is no longer posting here. said this was wrong forum. No need to create another post. I think you can help me with this sir.

    Code ( (Unknown Language)):
    1. void pin5_interrupt ()
    2. {
    3. if (INTCON.INTF==1)
    4.         {
    5.         INTCON.INTF=0;
    6.         //GPIO.F0=1;
    7.         //Vdelay_ms(dim_delay+offset_delay);
    8.         GPIO.F0=0;
    9.         delay_ms(1000);
    10.         }
    11.         GPIO.F0=1;
    12. }
    The above interrupt does not work even after the condition is met while debugging. I need help with this. What do you think is wrong?
     
  4. Dalaran

    Active Member

    Dec 3, 2009
    168
    0
    I don't know if you can specify an interrupt like that? Try:

    Code ( (Unknown Language)):
    1. void interrupt(void){
    2. }
    The above is working for me.

    You can also use the below for "low priority" interrupts:
    Code ( (Unknown Language)):
    1. void interrupt_low(void){
    2. }
    Cheers.
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    1. Exactly what are you trying to do?
    2. What MCU are you using?
    3. What makes you think the interrupt is being triggered?
    4. Post all of you code.
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Dalaran posted the solution.
    Blackmamba was not following the correct prototype for interrupt handling.
    Had Blackmamba looked at the documentation page I referred to (mikroC manual, the mikroC Language Reference under mikroC Specifics, on page 36) in the other thread, he would have seen the prototype:
    Code ( (Unknown Language)):
    1. void interrupt(void){
    2. }
    that Dalaran posted.
     
  7. Dalaran

    Active Member

    Dec 3, 2009
    168
    0
    Yup. Thanks sgt. Also I think the delay function is
    Code ( (Unknown Language)):
    1. Delay_ms()
    maybe the small "d" works. And (haven't checked in MikroC) but in MPLAB the limit for Delay_ms() was ~200, not sure if that applies here, but it might not be including the full delay. You could change that to a for loop though such as:

    Code ( (Unknown Language)):
    1. for(i = 0; i < 10; i++){
    2. Delay_ms(100);
    3. }
    Which will still give you your 1sec delay.

    GL.
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    MikroC and MikroC PRO will generate Delay_ms() as inline code.

    That means it will chew up some ROM if you call it multiple times, but one good side is that it is not limited to the number of mS. I often use Delay_ms(2000) etc to get a 2 second delay.

    If you are going to call the same delay period a lot, just wrap it in your own function like this;
    Code ( (Unknown Language)):
    1.  
    2. void My_Delay_2sec(void)
    3. {
    4.   Delay_ms(2000);
    5. }
    6.  
    As far as I know MikroC is not case sensitive on function names, but the newer MikroC PRO is case sensitive.

    If you click the text cursor on the function name, then press F1 button then Mikro C (and PRO) will bring up the help file for that function.
     
Loading...