Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7513

Bare metal, Assembly language • Can't read data from UART data register UARTDR on the RP2040

$
0
0
I have trouble understanding how to read from the uart controller using the UARTDR Register (4.2.8. of the datasheet) on the rp2040. The datasheet only contains SDK examples, for which there's a separate documentation, and I wasn't able to find any other information online. I have tried to use the registers in a more quicker to use environment but I have also failed at that. While I can successfully write to the controller using the register, only the read() function is able to do the opposite. You can see the code and its results below:

Code:

from machine import UART, Pin, mem32from time import sleepBASE = 0x40034000registers = [    0x18,    0x20,    0x24,    0x28,    0x2c,    0x030,    0x034,    0x038,    0x03c,    0x040,    0x044,    0x048    ]uart = UART(0, 9600)uart.init(baudrate=9600, tx=Pin(0), rx=Pin(1), bits=8, stop=1, parity=None)while 1:    print("register:\t", bin(mem32[BASE]))    print("uart.read():\t",uart.read(),'\n')    str = ''    for i in registers:        str += f"{hex(i)}: {bin(mem32[BASE+i])}\n"    print(str)    sleep(1)
Output:

Code:

register: 0b0uart.read(): b'message\r\n' 0x18: 0b1100101110x20: 0b00x24: 0b1001110000x28: 0b1000000x2c: 0b11100000x30: 0b11000000010x34: 0b00x38: 0b11100000x3c: 0b00x40: 0b00x44: 0b00x48: 0b11

Statistics: Posted by virus.exe — Thu Jun 19, 2025 5:39 pm — Replies 1 — Views 69



Viewing all articles
Browse latest Browse all 7513

Trending Articles