Difference between revisions of "Custom Interrupts - dsPIC/PIC24"

From Flowcode Help
Jump to navigationJump to search
Line 29: Line 29:
 
Handler code:
 
Handler code:
  
<font style="color:000080"> void _ISR _U1RXInterrupt(void)
+
<font style="color:#000080"> void _ISR _U1RXInterrupt(void)
  
 
{
 
{

Revision as of 10:45, 16 May 2013


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 <edit_icon_interrupt.htm>.


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)

{

FCM_%n(); // call selected macro

IFS0bits.U1RXIF = 0; // clear interrupt

}