UART Interrupt Question.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

UART Interrupt Question.

Post by seokgi »

Hello?
I am writing a serial program.
UART Interrupt does not work well.

MCU: 24FJ256GA406
UART 1: TX: B9
                 RX: B8
UART 2: TX: B15
                 RX: B14
UART 3: TX: F5
                 RX: F4
UART 4: TX: F3
                 RX: F2
UART 5: TX: D1
                 RX: D6
UART 6: TX: B7
                 RX: B12

The UART1,2,5,6 above works fine.
However, UART3,4 does not operate interrupt.

I do not know why.
Someone help me

Send the program.
Attachments
24FJ256GA406-test1.fcfx
(27.52 KiB) Downloaded 162 times

User avatar
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: UART Interrupt Question.

Post by Benj »

Hello,

The program you sent only seems to use UART channels 1 and 6. Can you send us a program that isn't working correctly.

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: UART Interrupt Question.

Post by seokgi »

Hi Benj.
It's a bit complicated but I upload my program.
I don't know what's wrong.
Please help.
Attachments
24FJ256GA406_1.fcfx
(60.54 KiB) Downloaded 161 times

User avatar
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: UART Interrupt Question.

Post by Benj »

Hello,

Looking at your program one thing jumps out at me and that is that you are sending data to RS232_6 in both the main loop (via the RS232_Monitor macro) and also from an interrupt (via the RS232_3_Receive_Char macro). This could potentially cause a problem and cause corruption or loss of data, I'm surprised the compiler isn't picking up on this.

It might be better to get rid of the send from the interrupt macro and then check CB3 for data to send on as part of the main loop.

The code for the four RX interrupts all looks ok in terms of the flowchart and the generated C code.

Enable code.

Code: Select all

    // Name: Interrupt, Type: Interrupt: Enable RXINT0
    IEC0bits.U1RXIE = 1;

    // Name: Interrupt, Type: Interrupt: Enable RXINT1
    IEC1bits.U2RXIE = 1;

    // Name: Interrupt, Type: Interrupt: Enable RXINT2
    IEC5bits.U3RXIE = 1;

    // Name: Interrupt, Type: Interrupt: Enable RXINT3
    IEC5bits.U4RXIE = 1;
Handler Code

Code: Select all

    //Handler code for [RXINT0]
    #ifndef MX_ISR_RX1
    #define MX_ISR_RX1
    void _ISR _U1RXInterrupt(void)
    {
        IFS0bits.U1RXIF = 0;
        FCM_RS232_1_Recive_Char();
    }
    #else
    #warning "This interrupt has previously been enabled, so the macro <RS232_1_Recive_Char> may never get called."
    #endif

    //Handler code for [RXINT1]
    #ifndef MX_ISR_RX2
    #define MX_ISR_RX2
    void _ISR _U2RXInterrupt(void)
    {
        IFS1bits.U2RXIF = 0;
        FCM_RS232_2_Recive_Char();
    }
    #else
    #warning "This interrupt has previously been enabled, so the macro <RS232_2_Recive_Char> may never get called."
    #endif

    //Handler code for [RXINT2]
    #ifndef MX_ISR_RX3
    #define MX_ISR_RX3
    void _ISR _U3RXInterrupt(void)
    {
        IFS5bits.U3RXIF = 0;
        FCM_RS232_3_Recive_Char();
    }
    #else
    #warning "This interrupt has previously been enabled, so the macro <RS232_3_Recive_Char> may never get called."
    #endif

    //Handler code for [RXINT3]
    #ifndef MX_ISR_RX4
    #define MX_ISR_RX4
    void _ISR _U4RXInterrupt(void)
    {
        IFS5bits.U4RXIF = 0;
        FCM_RS232_4_Recive_Char();
    }
    #else
    #warning "This interrupt has previously been enabled, so the macro <RS232_4_Recive_Char> may never get called."
    #endif

seokgi
Posts: 164
Joined: Fri Jan 13, 2012 4:21 am
Location: South KOREA
Has thanked: 18 times
Been thanked: 16 times
Contact:

Re: UART Interrupt Question.

Post by seokgi »

Dear Benj.
I tried the c code you sent me in several ways but it still doesn't work. I can't do c-language.
Let me know if there is a good way. Sorry for asking for help every time.

Please help me.

Thank you.
Attachments
AD4325_24FJ256GA406-1.fcfx
(50.64 KiB) Downloaded 159 times

User avatar
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: UART Interrupt Question.

Post by Benj »

I'm sorry the C code I sent is the code generated by Flowcode in your project, as you can see it is very simple and there is not really anything to go wrong.

It might be better to check your hardware for breaks or shorts. Maybe do some basic testing of each UART to try and see if you can spot a pattern in the behaviour to pinpoint the problem.

Post Reply