Go Down

Topic: Mega/Uno incompatible sketch. (Read 1 time) previous topic - next topic

delchrys

Hi i have a sketch working on a arduino Mega, it uses a rewritten hardwareserial library.
Now i want to upload it on my UNO, and yes i have rewritten the code because only one serial is available on the UNO. So i'm reading Serial data and sending it to softwareserial which i sniff with a USB/TTl adapter and Putty.

I think there are some alternations made in the hardwareserial that are not compatible with my UNO, i think it has to anything with different kinds of (registers/UCSR0A/UDR0 stuff)
Is there someone who knows how this works and who can check the alternated hardwareserial library for me.

I realy like to get it working on my UNO instead of Mega

holmes4


delchrys

yes thanks but i tried a lot of different options, but can't find the correct one.
Any hints?

delchrys

Datasheet!

Mark
can you please give me a hint, i'm bussy for three days for getting it to work.
I like the UNO to get some RX data from a EMS bus, the UNO has to decode it and send it through softserial to serail adapter so i can see the data.
Is it possible at the same time, or can't i use the 1 and only hardwareserial for this purpose???

Maybe something wrong with addressing or registers or baudrate????

MorganS

Why an UNO? Why can't you keep using the solution that already works?

If you need something smaller than a Mega, consider the Micro. It has hardware serial independent of the USB serial, so you can decode serial data and send it to the PC without any messing around with other hardware or softwareserial. If you need true serial-to-serial, then a Teensy is even smaller and has good hardware serial for 3 ports, plus USB serial too.
"The problem is in the code you didn't post."

ieee488

The Mega has 3 hardware serial ports. No need to user software serial.

UKHeliBob

The Mega has 3 hardware serial ports. No need to user software serial.
Does it not actually have 4 hardware serial ports ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

westfw

In what way have you changed the Serial code, and in what way does it not work?
I'm pretty sure that the ATmega2560 and ATmega328 UARTs are essentially identical...

"xxSerialxx.begin(9700);"   - really?  9700?

ieee488

Does it not actually have 4 hardware serial ports ?
I mis-remembered. That should be 3 hardware ports in addition to the one that comes Uno.
https://www.arduino.cc/en/Serial/Begin

westfw

Quote
yes i have rewritten the code because only one serial is available on the UNO. So i'm reading Serial data and sending it to softwareserial
If I try to compile your code, I get that nefitSerial1 is undefined.   I don't SEE anything in there that make nefitSerial1 be a SoftwareSerial port if the hardware doesn't exist; is this supposed to be the changed code, or the original Mega code?


delchrys

the example i posted was intended for the Mega,that's the one that works.

- Rewrite and use softwareserial on Mega works also.

- If i rewrite it to XXXSerial and use softserial it doesn't work on the UNO. The data won't be decoded and registers stay empty.



UKHeliBob

Why did you change the hardware serial library ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

delchrys

The hardwareserial is changed to detect the end/stop/break of the message , a 11bit Null.
And for the record I found the parts/sketches on the Internet and was planning of using it only for decoding the bus message. The rest I edit to fit my needs. Only the part thats edited in the hardwareserial I can't seem to understand fully understand.

delchrys

And I was using a uno cause I have another uno with wifi from arduino.org so I want to use that one to upload my data to my domoticz server.  So I'm looking for an arduino with multiple UARTS and wifi.

westfw

It might help if you post the code that isn't working...


Go Up