SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 270 | Next

Jan Axelson

"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems"


else
' Check other flags for enabled interrupts and take action as needed.
endif
RESUME
ENABLE
Ports for Embedded Systems
255
 The OpenUSART function enables the receive interrupt by setting the second
parameter to USART_RX_INT_ON:
OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_LOW,
77);
Another way to enable the serial-port receive interrupt is to set the bit directly:
PIE1bits.RCIE = 1;
If not using interrupt priority (IPEN = 0), set these bits:
// Disable using interrupt priority.
RCONbits.IPEN = 0;
// Enable all unmasked interrupts.
INTCONbits.GIE = 1;
// Enable all unmasked peripheral interrupts.
INTCONbits.PEIE = 1;
If using interrupt priority (IPEN = 1) and the serial interrupt is high priority,
set these bits:
// Enable using interrupt priority.
RCONbits.IPEN = 1;
// Configure the receive interrupt as high priority.
IPIR1bits.RCIP = 1;
// Enable all high-priority interrupts.
INTCONbits.GIEH = 1;
Chapter 11
256
This code sets up an ISR to respond to received serial-port data:
// Interrupt vector for high-priority interrupts.
#pragma code high_vector = 0x8
void interrupt_at_high_vector (void)
{
// Define the function to execute on an interrupt.
_asm goto high_isr _endasm
}
// The ISR function.
#pragma interrupt high_isr
void high_isr(void)
{
if ((PIR1bits.


Pages:
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282