Page 1 of 1

PIC18F4620 RS232 CUSTOM INT

Posted: Mon Dec 07, 2009 11:21 pm
by ALAN_26
HELLO

I'm trying to work with rs232 at the moment i managed to work connecting INT0 to the RX of the pic and trigger the interrupt
with falling the edge of the start bit , but sometimes the rs232 stops working and only restating the pic will get the rs232 to work again . so i think there must be a better way to do it

Anyone got any idea on how to make an rs232 custom interrupt for the 4620 please ?


Thanks in advance

Alan

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Tue Dec 08, 2009 9:39 am
by Benj
Hello Alan

The RS232 has a built in interrupt that will tell you when you have received a byte.

Create a custom interrupt with the following settings.
CustomInt.JPG
CustomInt.JPG (23.88 KiB) Viewed 6944 times
Once you have done this you may also have to call the RS232 read macro at the start of your program to ensure that any errors are cleared from the system before allowing the interrupt to run.

Inside your interrupt macro you can use the RS232 read macro to collect the byte that caused the interrupt.

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Tue Dec 08, 2009 3:48 pm
by ALAN_26
Thanks vey much Benj

I will try it tomorow and let you know

Thanks once againe

Best regards

Alan cilia

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Tue Dec 08, 2009 10:07 pm
by ALAN_26
hello Benj

The custom int works 100% tested thanks !
Just another question will the same interrupt work for other 18f MCU's ?


Alan

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Wed Dec 09, 2009 9:50 am
by Benj
Hello Alan

Yes the interrupt should work for pretty much any 18F or 16F device that has a hardware UART.

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Thu Dec 10, 2009 10:01 am
by beckemic
Hi!
I have the ECIO28 and ECIO40 MCU with PICs. I try to write the custom interrupt. But on the hardware it does not work. I think there is a problem in the chip setting. Can you tell me whether I should have a special chip setting? What else I can do wrong? The other Interrupts work well. Perhaps you can me tell more...
Thank you
Michaek

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Thu Dec 10, 2009 10:21 am
by Benj
Hello

Have you done this in your program?
You may also have to call the RS232 read macro at the start of your program to ensure that any errors are cleared from the system before allowing the interrupt to run.
If this doesnt allow the interrupt to work correctly then please can you attach your program to the forum and I will take a look for you.

Re: PIC18F4620 RS232 CUSTOM INT

Posted: Thu Dec 10, 2009 1:12 pm
by beckemic
Edit postDelete postReport this postReply with quote ECIO 24/40 PIC Problem with RX interrupt
by beckemic on Thu Dec 10, 2009 1:09 pm

Hi!

The Problem seems to be solved. But it only works if:
1. Before the interrupt is enabled the port must be read out.
2. The implemented RXINT does not work. It must be written as a customer interrupt:
enable code:
set_bit(intcon, GIE);
set_bit(intcon, PEIE);
set_bit(pie1, RCIE);
handler code:
if (test_bit(pir1, RCIF) && test_bit(pie1, RCIE))
{
cr_bit(pir1,RCIF);
FCM_%n();
}
Thank to the people of Matrix Multimedia for the nice help.
Bye
Michael