Page 1 of 1

soft serial

Posted: Mon Dec 18, 2023 8:33 am
by seokgi
I am working on a project using PIC18F45K40.
I need to use 4 UARTs. So two will use modbus and two will use soft serial.
A UART interrupt was created by referring to the data, but it does not compile.
Could you please help?
thank you.

Re: soft serial

Posted: Mon Dec 18, 2023 9:43 am
by medelec35
Hello.
The issue is the registers are wrong within the custom interrupt code.
E.g. for COM_A you have for Enable code:

Code: Select all

INTCONbits.PEIE = 1; // Enable peripheral interrupts
INTCONbits.GIE = 1; // Enable global interrupts
PIE1bits.RC1IE = 1; // Enable USART receive interrupts
Whereas it should be:

Code: Select all

INTCONbits.PEIE = 1; // Enable peripheral interrupts
INTCONbits.GIE = 1; // Enable global interrupts
PIE3bits.RC1IE = 1; // Enable USART receive interrupts
For the handler code you have:

Code: Select all

if (PIR1 & (1 << RC1IF)) // Check to see if the interrupt flag is set

{
FCM_%n(); // Call Flowcode Macro
PIR1bits.RC1IF = 0; // Clear interrupt flag
}
Instead of:

Code: Select all

if (PIR1 & (1 << RC1IF)) // Check to see if the interrupt flag is set

{
FCM_%n(); // Call Flowcode Macro
PIR3bits.RC1IF = 0; // Clear interrupt flag
}
I hope that helps?

Re: soft serial

Posted: Tue Dec 19, 2023 9:28 am
by seokgi
Thank you for your help.
But I don't understand why the register values change.
So I searched for MCU and found that PIC18F57Q43 is suitable.
But FC10 doesn't support it.
It seems that other people also want support for the Q43 series.
If possible, can you support the Q43 series?