Custom Interrupts
Posted: Tue Jul 22, 2008 4:19 pm
Can you help with with a custom interrupt for an RS-232 communication for the 16F877A and for the 18F452?
Thanks in advance
Thanks in advance
Old forums - please visit https://www.flowcode.co.uk/forums
https://www.flowcode.co.uk/mmforums/
Note that the "clear_bit(pir1, RCIF); // clear interrupt" line is not needed as this bit cannot be cleared in software. Instead, you must ensure that you read the incoming RS232 character within your interrupt macro using the "ReceiveRS232Char" macro call (or by directly reading the value using C code).Target PIC Processors ( PIC16F88 )
(Note: For other PICmicro 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:Disable code:Code: Select all
intcon.PEIE = 1; // Enable peripheral interrupts intcon.GIE = 1; // Enable global interrupts pie1.RCIE = 1; // Enable USART receive interrupts
Handler code:Code: Select all
pie1.RCIE = 0; // Disable USART receive interrupts
Code: Select all
if (pir1 & (1 << RCIF)) { FCM_%n(); // call selected macro clear_bit(pir1, RCIF); // clear interrupt }