Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

microprocessor interrupts

Options
  • 23-11-2006 2:20pm
    #1
    Registered Users Posts: 21,611 ✭✭✭✭


    i'm trying to use interrupts on a microprocessor. its not working and i have no idea why. its nothing to do with the hardware because it doesn't work in the MPLAB simulator using PIC C

    the INTF interrupt works (RB0) but the RBIF one doesn't. anyone know why its not working? am i missing something?
    #include <pic.h>
    
    main(void)
    {
    
    	INTE = 1;
    	RBIE=1;
    	PEIE=1;
    	GIE = 1;		
    
    	for(;;);
    }
    
    
    static void interrupt isr(void)			
    {
    	NOP();
    	if(INTF)
    	{
    		INTF=0;
    	}
    	if(RBIF) {				
    		RBIF=0;
    	}
    }
    
    
    


Comments

  • Closed Accounts Posts: 888 ✭✭✭themole


    how do you know its not working?

    You are checking a value and if true setting it to 0.

    So either way at the end of the isr both INTF=0;RBIF=0; , regardless of which was originally set.

    There is surely more to it than the code shown


  • Registered Users Posts: 21,611 ✭✭✭✭Sam Vimes


    themole wrote:
    how do you know its not working?

    You are checking a value and if true setting it to 0.

    So either way at the end of the isr both INTF=0;RBIF=0; , regardless of which was originally set.

    There is surely more to it than the code shown
    mplab has a function for animating a program where an arrow moves to the line that's currently being executed. when i simulate it, the arrow goes into the infinite loop and just stays there.

    i set up two buttons that trigger RB0 and RB1. when i click the RB0 button the arrow moves to the isr but when i click the RB1 button nothing happens

    there was other code but i cut it down to that to test the isr


    INTF is the RB0 interrupt flag and RBIF is the flag for the rest of portb. it has to be reset at the end of the interrupt service routine or it'll just loop


  • Closed Accounts Posts: 888 ✭✭✭themole


    i set up two buttons that trigger RB0 and RB1. when i click the RB0 button the arrow moves to the isr but when i click the RB1 button nothing happens

    Are they both set up to trigger an interrupt?
    Are you sure this is possbile?, some chips only allow interrupts to be triggered on certain lines.


Advertisement