Custom Interrupts - dsPIC/PIC24

From Flowcode Help
Jump to navigationJump to search

<sidebar>Sidebar: What Is an Interrupt?</sidebar> Here are a few examples for such interrupts using 16-bit PICmicro chips. To create interrupts that are not shown below you will have to refer to the device datasheet. Once the code has been placed into the custom interrupt properties dialog, the interrupt can be enabled and disabled like any of the standard Flowcode Interrupts.

Gen Custom Interrupts dsPIC-PIC24 USART.png


USART receive - This can be nicely integrated with the Flowcode RS232 component.

Target PIC Processor ( dsPIC30F2011 )

(Note: For other PIC devices you may have to refer to the device datasheet to obtain the correct code)


USART receive

The Flowcode RS232 component can be used to set the Baud rate and configure the mode of operation, and the ReceiveRS232Char function can be used in the handler macro to read the data (clearing the interrupt).


Enable code:

IEC0bits.U1RXIE = 1; //Enable USART receive interrupts


Disable code:

IEC0bits.U1RXIE = 0; //Disable USART receive interrupts


Handler code:

void _ISR _U1RXInterrupt(void) // U1RX Interrupt Handler Function

{

FCM_%n(); // Call Flowcode Macro

IFS0bits.U1RXIF = 0; // Clear Interrupt Flag - Rearm Interrupt

}