Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Arduino serial communication problems

2 posters

Go down  Message [Page 1 of 1]

1Arduino serial communication problems Empty Arduino serial communication problems Fri Dec 17, 2021 6:20 pm

feri



Arduino Uno Tx -->  Arduino Uno Rx
Sending:
Serial.print("ABCDEFGHILMNOPQRSTUVZ1234567890abcdefghilmnopqrstuvz")
I receive:
"ABCDEFGHI"
"LMNO"
"PQRSTUVZ1234567"
"890abcdef"
"ghilmnopqrstuvz"

Arduino Mega Tx -->  Arduino Mega Rx
I get different characters:

"#$%&'(),-./0123456:1234567890!"#$%&'(),-./0123456:!"#$%&'(),-./0123456:1234567890-*$'064',000.0,4,,,000.0,.,000.0,+*2$-*$'0''!,214527.406,4154.6540,.,01228.9080,%"

Arduino UNO Tx -->  Arduino Mega Rx
I get strange characters

I am attaching Tests.
Greetings
Attachments
Arduino serial communication problems AttachmentSerial Test.zip
You don't have permission to download attachments.
(15 Kb) Downloaded 3 times



Last edited by arcachofo on Fri Dec 24, 2021 2:33 am; edited 1 time in total (Reason for editing : Marked as solved (green color))

arcachofo likes this post

arcachofo

arcachofo

Issue solved at brach 1.0.0, Rev 712.

Issue in Arduino Uno: Receiving the string in chunks is normal if you don't detect "\r\n".

Issue in Arduino Mega:
I think it is good to explain this one, because it's related to the new MCU simulator and is the kind of errors that any user could solve by himself.

MCUs in this simulator are defined in xml files ( simulide/resources/data ).
Some problems are related to errors in these files.
These problems can be solved by the user just editing those files.

This Issue in Arduino Mega Usart in one example of an error in one of these files:
Atmega2560 (used in Arduino Mega) if defined in simulide/resources/data/AVR/mega2560.mcu

That file contains this:
Code:
<!DOCTYPE SimulIDE>

<mcu name="mega2560" core="AVR" data="8704" prog="262144" progword="2" eeprom="4096" inst_cycle="1">

    <include file="avr/avr_gpr.xml" />
    <include file="m640_1280_2560/m640_regs.xml" />
    <datablock name="RAM" start="0x0200" end="0x21FF"/>

    <include file="m640_1280_2560/m640_int.xml" />
    <include file="m640_1280_2560/m640_perif.xml" />
    
</mcu>
In the first line is defined: the core, data memory size, program memory size, program word size, eeprom size, instruction cycle clocks.

Then it includes other files:
Files ended in "_regs.xml" define Registers.
Files ended in "_int.xml" define Interrupts.
Files ended in "_perif.xml" define Perifericals.

In this case the error was in UCSR0C register ( file: m640_1280_2560/m640_regs.xml )
Code:
    <register  name="UCSR0C"  addr="0x00C2"  reset="00000110"  mask=""
               bits="UCPOL0,UCPHA0,UDORD0,USBS0,UPM00,UPM01,UMSEL0,UMSEL1" />
As you can see the Register bit names are incorrect, the correct ones are these:
Code:
               bits="UCPOL0,UCSZ00,UCSZ01,USBS0,UPM00,UPM01,UMSEL00,UMSEL01"

Just by editing this line the problem is solved.

Perifericals are defined in (relative path): m640_1280_2560/m640_perif.xml
In this case it was correct (just a typo in Usart number 2), but users can check if everything is correct.
For example first Usart is defined here:
Code:
    <usart name="USART0"  number="1" configregsA="UCSR0A" configregsB="UCSR0B" configregsC="UCSR0C">
        <trunit type="tx" pin="PORTE1" register="UDR0">
            <interrupt name="USART0_T" />
        </trunit>
        
        <trunit type="rx" pin="PORTE0">
            <interrupt name="USART0_R" />
        </trunit>
        
        <interrupt name="USART0_U" />
    </usart>
Some Register name, Pin name, Interrupt name, etc.  could be wrong creating a problem.

Note that adding a set of files like these you can add microcontrollers, even microcontrollers that don't exist.
The constrain is mostly in the perifericals, it must be periferical variants that are already implemented.

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum