Problem UART1 Mega2560

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

Moderator: Benj

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Problem UART1 Mega2560

Postby stregato » Sun Dec 11, 2016 6:05 pm

Goodmorning everyone
I ran several tests, but I can not use UART1 Interrupt with Arduino Mega2560 I tried with every door hardware without any success :?
Image

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: Problem UART1 Mega2560

Postby QMESAR » Sun Dec 11, 2016 6:28 pm

Hi
Are you testing on Real hardware or in the simulator not sure but I think interrupts is not supported in simulation

I am interested in this question as well :D

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Re: Problem UART1 Mega2560

Postby stregato » Sun Dec 11, 2016 7:38 pm

QMESAR wrote:Hi
Are you testing on Real hardware or in the simulator not sure but I think interrupts is not supported in simulation

I am interested in this question as well :D



No I'm performing the tests directly on the hardware simulation of interrupts know that does not work :?

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Re: Problem UART1 Mega2560

Postby stregato » Tue Dec 13, 2016 1:28 pm

:| I notice the problem nobody cares even a simple response from the employees could give pleasure :|

User avatar
LeighM
Matrix Staff
Posts: 1920
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 650 times
Contact:

Re: Problem UART1 Mega2560

Postby LeighM » Tue Dec 13, 2016 2:07 pm

Sorry, I'll take a look now :oops:
(I read this post at home at the weekend, so the read flag got set :roll:

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Re: Problem UART1 Mega2560

Postby stregato » Tue Dec 13, 2016 3:23 pm

LeighM wrote:Sorry, I'll take a look now :oops:
(I read this post at home at the weekend, so the read flag got set :roll:




I wish to thank you for your concern :roll:

User avatar
LeighM
Matrix Staff
Posts: 1920
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 650 times
Contact:

Re: Problem UART1 Mega2560

Postby LeighM » Tue Dec 13, 2016 3:52 pm

Hi,

I have not managed to find an ATmega2560 to test this on, but have tested with an ATmega1281 and found that the UART1 interrupt worked OK.
Would you like to post your program so that we can check it over?

Thanks
Leigh

EtsDriver
Valued Contributor
Valued Contributor
Posts: 413
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 328 times
Been thanked: 211 times
Contact:

Re: Problem UART1 Mega2560

Postby EtsDriver » Tue Dec 13, 2016 11:01 pm

******** REMEMBER TO FIRST APPLY THE NEWEST PATCHED V7.1.1.0 files!!**********
--> Just to be sure we dont try to solve anything that has been allready solved... :D

I investigated this a bit with Arduino Mega2560 (older one). (With old bootloader, changed to newer v2 bootloader and then without bootloader.) All worked fine.

Connected a simple wire from RX0 to RX1 to trigger the RX1 interrupt.

Attached program proves that RX1 interrupt works, try disabling or enabling this bit of code and load to arduino (i used Xloader to load .hex files to device) and see what happens:
disabling.PNG
disabling.PNG (17.7 KiB) Viewed 4738 times


I have to remind you to "flush" (by reading it) the UDR1 register in the macro for example to make program work more faster. If this is not done, the macro might not fire anymore or fires at very long interval (you can see this by looking at your TX led and sending a character to arduino).
This attached program dumps the Atmega internal registers to user and shows that there is data available on the receive buffer of UART1. If you put the UDR "reading" on in the UART1int macro, you see that the macro fires and the UDR printout shows some small value.

If value is 160, the UDR1 has not been flushed(=read to any variable):
UDR not empty.PNG
UDR not empty.PNG (3.72 KiB) Viewed 4738 times


To flush UDR1 register, you must use variable (remember to put FCV_ in front of and variable name in uppercase).

Code: Select all

FCV_MYVAL1 = UDR1;


After flushing UDR1:
UDR1_cleared.PNG
UDR1_cleared.PNG (19.93 KiB) Viewed 4738 times


tested same on UDR0, if not emptied shows something like this:
UDR not empty after sending J.PNG
UDR not empty after sending J.PNG (2.93 KiB) Viewed 4738 times



BTW as a side product from this investigation: To kill your arduino serial communications easily, try setting the UDR0 to 0... Program jams pretty fine. :mrgreen:
Attachments
uarttest_2560.fcfx
(17.87 KiB) Downloaded 94 times
These users thanked the author EtsDriver for the post:
LeighM (Wed Dec 14, 2016 10:48 am)
Rating: 5.26%
 
Ill just keep the good work up!

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Re: Problem UART1 Mega2560

Postby stregato » Tue Dec 13, 2016 11:29 pm

I tried with UART channel 2 channel 3 and channel 4
Attachments
PRM_prova1_mega_flowcode_problem_interrupt.fcfx
(26.6 KiB) Downloaded 90 times

User avatar
LeighM
Matrix Staff
Posts: 1920
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 461 times
Been thanked: 650 times
Contact:

Re: Problem UART1 Mega2560

Postby LeighM » Wed Dec 14, 2016 10:51 am

Could it be the receive string in the interrupt macro that is causing an issue?
Maybe try outputting a high to a pin at the start of the interrupt macro and set low at the end, to test if the routine is being entered, and exited.

User avatar
stregato
Posts: 18
Joined: Tue Feb 25, 2014 12:28 am
Been thanked: 3 times
Contact:

Re: Problem UART1 Mega2560

Postby stregato » Wed Dec 14, 2016 2:30 pm

I make a premise when using UART0 RX works fine I wanted to use UART1 RX to not have to continue to pull the interface that connects to UART0 port that is clearly used by the programmer, I understand that the problem is not resolved continue to connect and disconnect the interface Thanks for the help :roll:

EtsDriver
Valued Contributor
Valued Contributor
Posts: 413
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 328 times
Been thanked: 211 times
Contact:

Re: Problem UART1 Mega2560

Postby EtsDriver » Thu Dec 15, 2016 10:31 am

Hi!
rs232_init_missingh.PNG
rs232_init_missingh.PNG (14.08 KiB) Viewed 4685 times

I see your program is missing RS232 init..

And here is a tiny suggestion for receiving data on RXint:
You could do the receiving using something like this, as this will time out if timeout is specified or if the \r is received, it will jump out.

I personally use this bit more sophisticated method, but usually on UART0:
RXINT_1_RECEIVE.PNG
(23.61 KiB) Downloaded 1214 times
These users thanked the author EtsDriver for the post:
LeighM (Thu Dec 15, 2016 10:51 am)
Rating: 5.26%
 
Ill just keep the good work up!

maxtisc
Posts: 75
Joined: Mon Dec 23, 2013 9:34 pm
Has thanked: 2 times
Been thanked: 8 times
Contact:

Re: Problem UART1 Mega2560

Postby maxtisc » Mon Jan 02, 2017 12:16 am

Salve Stregato
Volevo sapere se sei riuscito a risolvere il problema dell' interrupt rx sul mega2560, è lo stesso problema che ho anch' io e non sò come venirne a capo
grazie dell' attenzione


Hi Stregato
I wanted to know if you managed to solve the problem of 'rx interrupt on Mega2560, is the same problem I too' and I do not know how to deal with them
Thanks for your attention