Can you help with with a custom interrupt for an RS-232 communication for the 16F877A and for the 18F452?
Thanks in advance
Custom Interrupts
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Re: Custom Interrupts
This is from the Flowcode help file:
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 }
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Custom Interrupts
Hello
This should work for both the 877A and the 452, however I have not tested it.
Enable Code
pie1.RCIE = 1;
intcon.PEIE = 1;
Disable Code
pie1.RCIE = 0;
Handler Code
pir1.RCIF = 0;
This should work for both the 877A and the 452, however I have not tested it.
Enable Code
pie1.RCIE = 1;
intcon.PEIE = 1;
Disable Code
pie1.RCIE = 0;
Handler Code
pir1.RCIF = 0;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Custom Interrupts
Actually Steve's code looks better, I would go with that.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel