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

From Flowcode Help
Jump to navigationJump to search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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>.  
+
<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 [[Interrupt Icon Properties|Interrupts]].  
 +
[[File:Gen_Custom Interrupts_dsPIC-PIC24_USART.png|right]]
 
   
 
   
  
Line 11: Line 13:
 
'''USART receive'''
 
'''USART receive'''
  
[[File:Custom Interrupts_dsPIC/PIC24_USART.png|right]]
 
 
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).
 
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:
+
'''Enable code:'''
  
 
<span style="color:#000080"> IEC0bits.U1RXIE = 1; //Enable USART receive interrupts </span>
 
<span style="color:#000080"> IEC0bits.U1RXIE = 1; //Enable USART receive interrupts </span>
  
 
   
 
   
Disable code:
+
'''Disable code:'''
  
 
<span style="color:#000080"> IEC0bits.U1RXIE = 0;  //Disable USART receive interrupts </span>
 
<span style="color:#000080"> IEC0bits.U1RXIE = 0;  //Disable USART receive interrupts </span>
  
 
   
 
   
Handler code:
+
'''Handler code:'''
  
<font style="color:#000080">void _ISR _U1RXInterrupt(void)
+
<font style="color:#000080">void _ISR _U1RXInterrupt(void) // U1RX Interrupt Handler Function
  
 
{
 
{
  
FCM_%n(); // call selected macro
+
FCM_%n(); // Call Flowcode Macro
  
IFS0bits.U1RXIF = 0; // clear interrupt
+
IFS0bits.U1RXIF = 0; // Clear Interrupt Flag - Rearm Interrupt
  
 
} </font>
 
} </font>

Latest revision as of 15:21, 21 January 2015

<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

}