Problem UART1 Mega2560

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

Moderator: Benj

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

Problem UART1 Mega2560

Post by stregato »

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: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Problem UART1 Mega2560

Post by QMESAR »

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

Post by stregato »

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

Post by stregato »

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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem UART1 Mega2560

Post by LeighM »

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

Post by stregato »

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: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem UART1 Mega2560

Post by LeighM »

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
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

Re: Problem UART1 Mega2560

Post by EtsDriver »

******** 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
(17.69 KiB) Downloaded 5221 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
(3.72 KiB) Downloaded 5221 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
(19.93 KiB) Downloaded 5221 times
tested same on UDR0, if not emptied shows something like this:
UDR not empty after sending J.PNG
(2.93 KiB) Downloaded 5221 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 273 times
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

Post by stregato »

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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem UART1 Mega2560

Post by LeighM »

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

Post by stregato »

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
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

Re: Problem UART1 Mega2560

Post by EtsDriver »

Hi!
rs232_init_missingh.PNG
(14.08 KiB) Downloaded 5168 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
Ill just keep the good work up!

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

Re: Problem UART1 Mega2560

Post by maxtisc »

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

Post Reply