Axi_uartlite_0.register_map gives error

Hello All,

I am trying to implement a UART communication from PYNQ PS using python to a HC-05 module. But, I am not able to access the register_map attribute of the uartlite ip in order to send the data to HC-05.

Currently, I am using the following code that is sending random variables on my app.

Below is the python code I am using,

from pynq import Overlay
from pynq import MMIO
import time

overlay = Overlay('/home/xilinx/pynq/overlays/sample_b/test_bt_overlay.xsa')
print(overlay)

#print(f'Available IPS are: {overlay.ip_dict}')

uart_ip = overlay.axi_uartlite_0
print(uart_ip)

#print(overlay.ip_dict['axi_uartlite_0'])

#Accessing TX and RX of UART
UART_BASE_ADDR = 0x42C00000
UART_ADDR_RANGE = 0x10000

uart = MMIO(UART_BASE_ADDR, UART_ADDR_RANGE)

STATUS_REG_OFFSET = 0x08
TX_EMPTY_MASK = 0x04
TX_FIFO_OFFSET = 0x04
CTRL_REG_OFFSET = 0x0C

uart.write(CTRL_REG_OFFSET, 0x03)
time.sleep(0.01)
uart.write(CTRL_REG_OFFSET, 0x00)

def uart_send_byte(data):
    while not (uart.read(STATUS_REG_OFFSET) & (TX_EMPTY_MASK)):
        pass
    uart.write(TX_FIFO_OFFSET, data)

var = 'H\n'
for i in var:
    uart_send_byte(ord(i))

Is there any method to resolve this issue and perform communication perfectly?
And also why I am not able to access the register_map attribute in order to send the data?

The app I am using is Serial Bluetooth Terminal to observe the data being transmitted

Hi @Veman,

What board are you using?
What PYNQ SD card image are you using?

Even if the register map is not available the DefaultIP driver with MMIO should be assigned.
Is the code you show working?

Mario

I am working on PYNQ Z2 board with PYNQ-3.0.1.

The code I have attached with the header post is sending the data. But, on the receiving end I am seeing all random values that are out of ASCII range.

On the receiving end I have an app named Serial Bluetooth Terminal.

Did you configure the baudrate in the reception the same as baudrate in the transmission?

Yes, both sides I am using 9600 as the Baud rate.

1 Like