I am trying to create a updi programmer out of an esp32-c3-mini and I am able to configure the hardware uart like this and I can snoop on UPDI commands sent by things like jtag2updi successfully.
uart_config_t uart_config = {
.baud_rate = UPDI_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_2,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_APB,
};
However when I try to send commands and flip the direction to read results I never seem to get anything back.
Without going into too much detail about all the approaches I've taken, does anybody have any insight on what I might be doing wrong or what I need to do?
uart half duplex one line
Re: uart half duplex one line
Interested in this also - have a board with an ESP32-S3 main processor and an Attiny1616 for background input monitoring. Would love to be able to UPDI program the Attiny via the ESP.
Don't have any suggestions unfortunately. Just leaving a comment to get notified of replies
Don't have any suggestions unfortunately. Just leaving a comment to get notified of replies
Re: uart half duplex one line
Bump, after some insight from another thread I feel I may have sorted out what is effectively half-duplex by merging a tx/rx line together and then doing something like this:
At least, I am able to snoop on an active connection between two devices when I have both my rx/tx line connected in and use this -- I can also send on my tx and immediately read it back on my rx.
However, I'm still having trouble getting a response from my attiny so I can't confirm whether this is the full solution.
Any other input would be appreciated!
Code: Select all
// UART configuration
uart_config_t uart_config = {
.baud_rate = UPDI_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_2,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_APB,
};
// Configure UART parameters
uart_param_config(UPDI_UART_NUM, &uart_config);
// Set UART pins
uart_set_pin(UPDI_UART_NUM, UPDI_RX_PIN, UPDI_TX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
// Install UART driver
uart_driver_install(UPDI_UART_NUM, 1024 * 2, 0, 0, NULL, 0);
// Set UART read timeout
uart_set_rx_timeout(UPDI_UART_NUM, 50);
const gpio_config_t pin_cfg {
.pin_bit_mask = (1ul << GPIO_NUM_8) | (1ul << GPIO_NUM_2),
.mode = GPIO_MODE_INPUT_OUTPUT_OD, // Input and Output w/ open-drain!
.pull_up_en = GPIO_PULLUP_ENABLE, // Open-drain requires a pull-up.
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE
};
gpio_config(&pin_cfg);
esp_rom_gpio_connect_out_signal(UPDI_TX_PIN, UART_PERIPH_SIGNAL(UPDI_UART_NUM, SOC_UART_TX_PIN_IDX), false, false);
esp_rom_gpio_connect_in_signal(UPDI_RX_PIN, UART_PERIPH_SIGNAL(UPDI_UART_NUM, SOC_UART_RX_PIN_IDX), false);
However, I'm still having trouble getting a response from my attiny so I can't confirm whether this is the full solution.
Any other input would be appreciated!
-
- Posts: 4
- Joined: Tue Oct 04, 2022 2:04 am
Re: uart half duplex one line
Does this help https://github.com/jouellnyc/UART/blob/ ... /README.md ?
I know it's not the same but it's similar and different - and it's micropython.
I basically quickly made a wire a sender and then a receiver via a UART and RS-485
I know it's not the same but it's similar and different - and it's micropython.
I basically quickly made a wire a sender and then a receiver via a UART and RS-485
-
- Posts: 1697
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: uart half duplex one line
I guess my reply in the other thread wasn't very visible, so:
UPDI wants a BREAK signal to reset/synchronize communication. When you were snooping on the communication, the BREAK that was sent may well have gone unnoticed by your code, but you'll have to send one at the start of your own exchange.
Did you already do that? If yes, how did you do it (GPIO vs. UART driver)?
Re: uart half duplex one line
So I have way too many details to cover here, but I think I am pretty confident the issue is still line contention.
I am sending the exact same break + updi commands in the exact same serial format as jtag2updi but I don't get a response.
I thought I would test something, I connected jtag2updi in together with my tx/rx and target device, I was able to program the device with jtag2updi, then I initialized my serial tx/rx and sent a updi handshake and updi command, after that I tried to use jtag2updi and it wouldn't work reporting no device power.
When I unplug the tx line (but leave the rx line connected) jtag2updi begins to work.
So very clearly my tx line is still causing contention, even with open-drain, any tips?
I am sending the exact same break + updi commands in the exact same serial format as jtag2updi but I don't get a response.
I thought I would test something, I connected jtag2updi in together with my tx/rx and target device, I was able to program the device with jtag2updi, then I initialized my serial tx/rx and sent a updi handshake and updi command, after that I tried to use jtag2updi and it wouldn't work reporting no device power.
When I unplug the tx line (but leave the rx line connected) jtag2updi begins to work.
So very clearly my tx line is still causing contention, even with open-drain, any tips?
Who is online
Users browsing this forum: No registered users and 69 guests