Microcontroller ATmega644P (RX and TX)

Status
Not open for further replies.

batman69

New member
Hi everyone,

I would like to ask you guys if you could help me out with the following issue.


I am a little stuck but at the same time confused. I am trying to work with the RX and TX pins of the ATmega644P, but I am getting some strange responses.

This is the issue. I have an electronic board with the ATmega644PA microncontroller managing all the electronic components. The board has, among others things, a connector for a bluetooth module (I am using the HC-06) and which I pretend to establish communication between the microcontroller and the bluetooth module using the RX and TX pins.

The thing is that I have been able to transmit from the Arduino IDE to the software terminal (CoolTerm). However, for some incomprehensible reason, I can get the data on the Arduino IDE when I try to send something back from Coolterm to the Arduino IDE.

I am using the Sanguino firmware/board for the ATmega644PA. I have switched the RX and TX pins between the microcontroller and the connector but nothing happens. Only I am able to send data from Arduino IDE to the CoolTerm.


I tried out both the Bluetooth module and the code in a Arduino UNO and it perfectly worked at the first try (I used the SoftwareSerial library)


After spending a lot time (more than one month) I do not know exactly what the problem could be. I am using the SoftwareSerial.h in the sketch as a serial library because I am using the pins 40 and 41 of the mircrocontroller. The board has those pins already set up (traces) to do the function of transmitting (TX) and receiving (RX). The Atmega644PA has two UART. I am using the "Serial".

I think the problem is with the libraries. The SoftwareSerial library works on Arduino UNO well but no on Atmega644PA. This week I tried out the different software serial libraries which use the RX and TX pins for serial communications on Arduino UNO and the outcomes were:

- NeoSWSerial library: it only allowed to transmit from Arduino UNO to the Software Terminal (Coolterm). No getting back data on Arduino UNO

- AltSoftSerial library: it did not work at all on Arduino UNO. No transmitting, no receiving.

- SofwareSerial library: it worked perfectly, transmitting and receiving.


In the three cases the code was the same.


My thoughts go to the direction of the libraries. For some reason, these libraries create a intern conflict or whatever when using them on the Atmega644PA. Out of the three. only SoftwareSerial allows to transmit data from Arduino UNO to CoolTerm (no sending back from Coolterm to Arduino UNO)



Does someone have any thoughts?.


Thank you so much in advance.

Kindly Regards
 
Hm,
This is a forum about Teensy boards. The 3.x boards have ARM processors, not AVR.
Well, with a Teensy you have up to 6 "real" (hardware) UARTS, so you could have saved weeks.. :)

https://www.pjrc.com/teensy/td_uart.html

In addition 1x real USB Port which can be a "Serial" for connection with the PC, too.

Stopp fiddling, buy a better board, with way more memory and speed :)
 
Agree, you should use *real* serial ports.

SoftwareSerial is full of hidden problems and unpleasant surprises when you try to use multiple serial ports. SoftwareSerial appears to work flawlessly when you test with data flow to only 1 serial device. But it is a false confidence. When you have simultaneous communication to other serial ports, SoftwareSerial blocks interrupts needed by the other ports! If the baud rate on SoftwareSerial is slow, the interrupt blocking is for too long and causes data loss on the other ports. Even faster baud rates on SoftwareSerial causes substantial CPU hogging (on such a slow board without much CPU power) that lowers performance of everything else.

SoftwareSerial is a mediocre solution on boards like Arduino Uno where you do not have *any* extra serial ports. It tends to work if you avoid also sending data from your PC to Arduino Uno while SoftwareSerial is communicating. But as soon as you try simultaneous communication, you'll very likely experience problems.

Teensy LC (the least expensive Teensy for under $12) has 3 real serial ports, plus separate USB serial to your PC which does not conflict. You should really use a better board with real serial ports, like Teensy LC or Teensy 3.2 or 3.5. Save those limited AVR chips for simpler projects not needing simultaneous serial communication.
 
Hi guys!

First of all, thank you so much for your answers, and secondly, my apologies for getting you back late. Sorry. I really appreciate your answers despite the forum is not for AVR microcrontrollers.

With regard to the "SoftwareSerial" library, I had suspicious that this library might affect the right working of the code/board. That's why I decided to get some feedbacks from experts.

I do not know if you guys might be answer another question/doubt I have. I know it is not probably the right place to make questions about AVR, but I would like to take the opportunity and to ask you guys something else (if it can be answered I will get happy, if not I will get double happy for the answers of the previous question). The thing is that I have seen on this website (Paul Stoffregen's), in the secion "Using the Hardware Serial Ports" a piece of code very similar that the one I am using in my initial project with the Atmega644PA. Based on this code, I have realized that in order to get to work the "real" serial ports (UART) one the most or may be the most convinient library is "HardwareSerial" (HWSERIAL). But, I drew my attention that the way of using this library is a bit different from the other ones. The others serial libraries have to "included" (#include), but with this one, "HWSERIAL", apparently has to be defined and to specify the Serial Port to use (#define HWSERIAL Serial1).

Why does HWSERIAL has to be defined and not included? and if I want to use this library on Arduino IDE, do I have to do the same? That is, do I have to "define" it instead of "include" it specifying the Serial Port to use?

Again, thank you so much for your help guys. I really appreciate any help.

Kindly regards.
 
There are AVR Teensy units in the 'Teensy' source tree, but that is code in the Teensy3 ARM family of the PJRC products.

The Actual hardware serial ports for ARM Teensy3 family each have their own file Serial# where # may be [1-6] depending on the device, those files include the HardwareSerial.h file for reference information.
 
When you ask a question about a particular library or example, please be specific with a link to the exact code, or a copy of the code if it's not readily available on a website.

I have published hundreds of examples, between libraries, web pages, github repositories and examples that come with Teensyduino. Many are similar. So are lots of others written by many other people. Details matter.
 
Hi guys!

Thank you so much again for your answers.

My apologies for not being more specific. Well, maybe I made a mistake expressing myself, but what I wanted to say it was if the use of the HardwareSerial library with Adruino IDE was the same one that with Teensy. I have spent part of the day searching information about the use of HardwareSerial library in Arduino IDE and now I think it is a bit clearer.

Either way, thank so much for your replies. I really appreciate them. I will get back to you guys if I have a doubt.

Regards.
 
Status
Not open for further replies.
Back
Top