Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Anyone who can help me / explain how the uart communication works?

Status
Not open for further replies.

Winch

Member
I try to understand what is happening in the code.
The intention is to let two ATmega32U4 talk to each other.
I think I should have more information on how to properly receive the code at the receiver.
How do you decode the serial signal back to what you sent earlier? In my case the number 128.

For one ATmega32u4 I have the following code.

Code:
'* Date start project: 03-05-2020
'* Hardware version  : Hardware = Arduino Leonardo PCB
'* Firmware-version  : Beta (version 1.0)
'* Microcontroller   : ATmega32U4
'* Notes             :
'****************************************************************

Define CLOCK_FREQUENCY = 16

Define SEROUT_DELAYUS = 5000

DDRD.3 = 1  'output
DDRF.1 = 0  'input ADC1, input PF1

Dim Pot As Byte

Symbol TX = PORTD.3

WaitMs 500

Pot = 128

Main:
        Serout TX, 600, #Pot, CrLf
Goto Main
End

And for the receiver I have the code below.

Code:
'* Date start project: 03-05-2020
'* Hardware version  : Hardware = Arduino Leonardo PCB
'* Firmware-version  : Beta (version 1.0)
'* Microcontroller   : ATmega32U4
'* Notes             :
'****************************************************************

Define CLOCK_FREQUENCY = 16

Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4
Define LCD_RSREG = PORTC
Define LCD_RSBIT = 6
Define LCD_EREG = PORTD
Define LCD_EBIT = 7
Define LCD_RWREG = PORTD
Define LCD_RWBIT = 0

DDRD.2 = 0  'input
DDRD.4 = 1

Symbol RX = PORTD.2

Dim Value As Word

Lcdinit 0
WaitMs 500

Value = 0

Main:
    Serin RX, 600, Value

    Lcdcmdout LcdLine2Home
    Lcdout "= ", #Value
   
Goto Main
End
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top