When using UART and TWAI the API wants both RX and TX pin be set to something. I only need to listen so TX pins is not needed.
I want to save those pins for something else and I don't want the API to configure TX pins of UART and TWAI.
How to use RX pin only without TX pins in UART and TWAI?
How to use RX pin only in UART and TWAI?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to use RX pin only in UART and TWAI?
Generally for ESP-IDF drivers, you can pass '-1' as a GPIO not to assign anything. Alternatively, just select any existing GPIO, then after the driver is initialized, configure the GPIO to be something else.
Re: How to use RX pin only in UART and TWAI?
I'm testing on ESP32C3 and I get this when I have:ESP_Sprite wrote: ↑Wed Aug 21, 2024 2:57 amGenerally for ESP-IDF drivers, you can pass '-1' as a GPIO not to assign anything. Alternatively, just select any existing GPIO, then after the driver is initialized, configure the GPIO to be something else.
Code: Select all
static const twai_general_config_t g_config = {.mode = TWAI_MODE_LISTEN_ONLY,
.tx_io = -1,
.rx_io = 7,
.clkout_io = TWAI_IO_UNUSED,
.bus_off_io = TWAI_IO_UNUSED,
.tx_queue_len = 0,
.rx_queue_len = 5,
.alerts_enabled = TWAI_ALERT_NONE,
.clkout_divider = 0};
Code: Select all
expression: twai_driver_install(&g_config, &t_config, &f_config)
abort() was called at PC 0x40385307 on core 0
Core 0 register dump:
MEPC : 0x4038085a RA : 0x40385312 SP : 0x3fc91b70 GP : 0x3fc8e400
TP : 0x3fc91c70 T0 : 0x37363534 T1 : 0x7271706f T2 : 0x33323130
S0/FP : 0x00000004 S1 : 0x3fc91bd4 A0 : 0x3fc91b9c A1 : 0x3fc91bd2
A2 : 0x00000000 A3 : 0x3fc91bc9 A4 : 0x00000001 A5 : 0x3fc90000
A6 : 0x7a797877 A7 : 0x76757473 S2 : 0x00000000 S3 : 0x00000000
S4 : 0x00000000 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x6e6d6c6b T4 : 0x6a696867 T5 : 0x66656463 T6 : 0x62613938
MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000007 MTVAL : 0x00000000
MHARTID : 0x00000000
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to use RX pin only in UART and TWAI?
Ah, I guess TWAI has its own define for that. You can try passing TWAI_IO_UNUSED.
If not, as I said, just use a random GPIO and re-initialize it for some other purpose later.
If not, as I said, just use a random GPIO and re-initialize it for some other purpose later.
Who is online
Users browsing this forum: Google [Bot], snutw_ and 136 guests