Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UART function definitions are missing #63

Open
abdullahyildiz opened this issue Feb 14, 2023 · 9 comments
Open

UART function definitions are missing #63

abdullahyildiz opened this issue Feb 14, 2023 · 9 comments

Comments

@abdullahyildiz
Copy link

abdullahyildiz commented Feb 14, 2023

It seems that definitions of the function declarations in uart.h are missing in firmware_vex:

#ifndef __UART_H
#define __UART_H

#ifdef __cplusplus
extern "C" {
#endif

#define UART_EV_TX	0x1
#define UART_EV_RX	0x2

void uart_init(void);
void uart_isr(void);
void uart_sync(void);

void uart_write(char c);
char uart_read(void);
int uart_read_nonblock(void);

#ifdef __cplusplus
}
#endif

#endif
@abdullahyildiz
Copy link
Author

There is also no register defined for setting the UART baud rate (i.e., divisor) in csr.h. Is it included as a register field in one of the other CSRs?

@proppy
Copy link
Contributor

proppy commented Mar 15, 2023

@thesourcerer8 commented about getting uart to work here:
https://github.com/thesourcerer8/mpw2-stdcell-tests/blob/main/uart_test/uart_test.c

@proppy
Copy link
Contributor

proppy commented Mar 15, 2023

but it would be nice to also have the caravel UART defined in the nucleo micropython machine environment, currently it returns:

uart = UART(0, 9600)                         # init with given baudrate

from machine import UART
​
uart = UART(0, 9600)                         # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
uart.read()

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: UART(0) doesn't exist

@proppy
Copy link
Contributor

proppy commented Mar 16, 2023

@abdullahyildiz
Copy link
Author

@proppy,

As far as I know, MicroPython is a software stack which runs on Nucleo board and UART peripheral on Caravel management SoC is not controlled by MicroPython.

@proppy
Copy link
Contributor

proppy commented Mar 16, 2023

@abdullahyildiz yep, but the hardware pin that export the hardware bus are physically connected to the Nucleo board, so it should be possible to surface them to the micropython environment thru the HAL.

@abdullahyildiz
Copy link
Author

abdullahyildiz commented Mar 16, 2023

@proppy,

UART peripheral pins on management SoC is not connected to Nucleo board. We were able to interact with it by standard UART cable.

@proppy
Copy link
Contributor

proppy commented Mar 16, 2023

@abdullahyildiz I think they are electrically connected, UART is on E7 and F7, respectively mapped to mprj_io[5] and mprj_io[6] which onnect to CN11 PF0 and CN12 PE11 of the nucleo Morpho connector:
Screenshot_20230316-182716~3
but don't seem to be currently surfaced in the micropython HAL UART definitions.

@proppy
Copy link
Contributor

proppy commented Mar 17, 2023

found out that we can actually bridge one of the existing UART port defined here:
https://github.com/micropython/micropython/blob/master/ports/stm32/boards/NUCLEO_F746ZG/mpconfigboard.h#L38-L39

by setting the pin #9 to C_DISABLE in gpio_config_io.py and leaving its register untouched in set_registers and then physically bridging IO[9] (which correspond to MICROPY_HW_UART6_RX (G9) with IO[6] using a jumper cable:
IMG_20230317_182548

The data from the caravel serial port can then be read from the micropython environment using:

uart = machine.UART(6, 9600)
print(uart.read())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants