Page 1 of 1
Arduino Mega 2560 Interrupts
Posted: Thu Jul 18, 2019 7:17 pm
by mnf
Been playing with a Wemos Mega 2560 + ESP8266 board.
The interrupts are not defined for UART2 and UART3 Rx inetrrupts. (The interrupt definitions stop at 7 - Rx for UART 3 is 9 Tx is 10 for example - see datasheet page 90
https://ww1.microchip.com/downloads/en/ ... asheet.pdf)
This makes life a little trickier as the ESP8266 is connected via UART3.
The nomenclature is also confused - in some places (interrupts) referring to UART0 (..UART3) but the UART component refers to channel 1..4 for UART0 to UART3 - it would be simpler if this was consistent?
Martin
Re: Arduino Mega 2560 Interrupts
Posted: Fri Jul 19, 2019 9:32 am
by LeighM
Hi Martin,
I've added Rx interrupt support for UART2 and UART3, fcd attached.
This will be an unofficial update until it gets pushed out on the auto system next week.
Hope it helps
Leigh
ps. As for the naming, this is tricky as we use the name "Channel 0" for the software UART.
It's all a bit historic and inconsistency between devices. It's something we will need think about.
Re: Arduino Mega 2560 Interrupts
Posted: Fri Jul 19, 2019 11:01 am
by mnf
Many thanks,
will test it this evening....
Re: Arduino Mega 2560 Interrupts
Posted: Fri Jul 19, 2019 8:38 pm
by mnf
Cool - that works.
I copied the new interrupt data to the mega r3 fcdx file and updated FC to use the new file (using reset data files to get it to copy the fcdx files to it's working directory- not sure this is the right way to go about this)
Then - I couldn't compile my program. I got a redefinition of __vector_54 error.
Starting again from scratch - I managed to re-enter the same program, and couldn't replicate the error. Recompiling the original program fails. New one works

Delete the original and carry on.
So now the Arduino side of the board can communicate with the ESP side - all is well!
Discovered why original code wouldn't work - attempting to communicate with ESP chip by sending 'AT' and receive a response (I got "AT+CIPMUX=0" success) Adding the WLAN_ESP8266 component - which uses the interrupt internally and must define using the same name

. If ESP component is set up to use COM4 (correctly) then compilation fails (with redef error as above) - the WLAN_ESP8266 component is using the interrupt to retrieve data from the ESP chip. I wanted to check ESP chip was working correctly (having munged the firmware) - so wanted to just send AT commands. So need to do one or the another - manual 'AT' control or use the component. Now I know the ESP chip is working - the component beckons.... So - remove the new definitions for now.....
Martin
Re: Arduino Mega 2560 Interrupts
Posted: Sat Jul 20, 2019 7:01 pm
by mnf
In fact the interrupt seems to set up correctly but the ESP8266 not working at all though. No response to AT commands or initialisation from ESP component.
The string received was the intialisation string sent by the ESP component - I happened to have it set to UART1 - so it just got sent to putty terminal on PC.
Anyone any success reflashing the firmware on an ESP device to run AT commands?
I can connect directly to the ESP8266 and it is not responding to AT commands - does seem to be running, it sets up a wireless network, and I can run micropython on it, so the hardware is OK.
Martin
Re: Arduino Mega 2560 Interrupts
Posted: Sun Jul 21, 2019 9:48 pm
by mnf
... and finally got the ESP chip back up and running.
Can now run AT commands from the terminal

AT+GMR or AT+RST work for example.
Still can't get the Arduino and ESP sides talking however - ESP8266 component returns 0 and sending AT commands via an UART doesn't seem to have the desired result either.
An ESP-01 gives a MEM check fail on AT+RST too (via putty) - not had a succesful day
Martin
Re: Arduino Mega 2560 Interrupts
Posted: Sun Jul 21, 2019 10:19 pm
by maxtisc
hello LeighM and everyone
I inform you that the interrupt problem of the serial port channel 2 on the rx pin of the arduino 2560 and 2560R3 is also present in the FC7 version, while in FC6 it works correctly, I hope that you solve soon
Thanks
Re: Arduino Mega 2560 Interrupts
Posted: Mon Jul 22, 2019 10:19 am
by Benj
Hi Martin,
Still can't get the Arduino and ESP sides talking however - ESP8266 component returns 0 and sending AT commands via an UART doesn't seem to have the desired result either.
An ESP-01 gives a MEM check fail on AT+RST too (via putty) - not had a succesful day

Can you change the baud rate of the module using the terminal. 115200 is a hard baud rate for an AVR at 16MHz to achieve. Maybe start with 9600 and if this works then bump up the rate.
Hello,
I inform you that the interrupt problem of the serial port channel 2 on the rx pin of the arduino 2560 and 2560R3 is also present in the FC7 version, while in FC6 it works correctly, I hope that you solve soon
Can you send us the program that demonstrates the problem?
Re: Arduino Mega 2560 Interrupts
Posted: Mon Jul 22, 2019 8:30 pm
by mnf
Can you change the baud rate of the module using the terminal. 115200 is a hard baud rate for an AVR at 16MHz to achieve. Maybe start with 9600 and if this works then bump up the rate.
- Good idea. All working now. Program reports ESP8266 ready for action and connected to my WiFi seconds later.
Only tried 9600 (set using
sent via putty terminal to the ESP chip - will try faster later
Martin
Re: Arduino Mega 2560 Interrupts
Posted: Tue Jul 23, 2019 12:12 am
by maxtisc
hello benji
I also attach the 2 files, precise that the files were not imported but created all over again. The function in short is that pressing the send key to arduino a key recognition code and arduino sends a code to the display to open the new page
thanks for your interest, I hope I was clear
I wanted to upload 2 short videos but he won't let me, it would have been clearer
I hope it's not just my distraction and it won't waste your time
good job
Re: Arduino Mega 2560 Interrupts
Posted: Tue Jul 23, 2019 8:19 am
by LeighM

- uart_wrong.jpg (37.55 KiB) Viewed 8371 times

- uart_correct.jpg (39.08 KiB) Viewed 8371 times
Re: Arduino Mega 2560 Interrupts
Posted: Tue Jul 23, 2019 5:06 pm
by maxtisc
hi Benji
in fact I already use channel 2 (tx port_D2 rx port D3) in both the software, I also did another test, I compiled the fc6 file with fc7 but even this didn't work, recompiling it with fc6 returns to work, I managed to attach the two videos, I hope they can help you.