overklog
Newbie level 2
Hey guys
My interupt looks like it is working fine, when I press the button LED RD2 gets switched off till I let the button go then it switches back on again. However when I add a counter to check how many times the interupt get triggered it increaments with more than once for evey time I press the button. Here is the 2 segements high priority and main routine of my code. I left out the rest of the code since I have procedures interfacing via usb to the computer and also using 2 other timers on high priority aswell which iis about 1000 lines of code.
Thanks guys
My interupt looks like it is working fine, when I press the button LED RD2 gets switched off till I let the button go then it switches back on again. However when I add a counter to check how many times the interupt get triggered it increaments with more than once for evey time I press the button. Here is the 2 segements high priority and main routine of my code. I left out the rest of the code since I have procedures interfacing via usb to the computer and also using 2 other timers on high priority aswell which iis about 1000 lines of code.
Code:
//These are your actual interrupt handling routines.
#pragma interrupt YourHighPriorityISRCode
void YourHighPriorityISRCode()
{
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////// Pin Interupt
/////////////////////////////////////////////////////////////////////////////////////////////////
if ( INTCONbits.INT0IF)
{
WS1 = WS1 + 1; // WS = Wheel sensor
INTCONbits.INT0IF = 0;
}
}
int main(void)
#endif
{
InitializeSystem();
#if defined(USB_INTERRUPT)
USBDeviceAttach();
#endif
while(1)
{
#if defined(USB_POLLING)
// Check bus status and service USB interrupts.
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// frequently (such as once about every 100 microseconds) at any
// time that a SETUP packet might reasonably be expected to
// be sent by the host to your device. In most cases, the
// USBDeviceTasks() function does not take very long to
// execute (~50 instruction cycles) before it returns.
#endif
// Application-specific tasks.
// Application related code may be added here, or in the ProcessIO() function.
ProcessIO();
if (PORTBbits.RB0 == 1) // button pushed
{
LATD = 0x00;
//INTCONbits.INT0IF = 0;
}
if (PORTBbits.RB0 == 0)
{
LATD =0x02;
}
}//end while
}//end main
Thanks guys