I would like to use the RMT peripherial to read VAN bus protocol, but I have a hard time to figure out how to get the correct timings. I wrote an analyzer plugin for Saleae https://github.com/morcibacsi/VanAnalyzer so I know how the protocol looks like. There is also a description on it here: http://graham.auld.me.uk/projects/vanbu ... tocol.html. The point is that I need to sample the input in every 8us (microseconds) but I cannot get my head around the formula to calculating it. I found a simple (at least it seems so) example here in the forums: https://www.esp32.com/viewtopic.php?t=5787, but still no luck.
Code: Select all
#define RMT_RX_CHANNEL 0 /* RMT channel for receiver */
#define RMT_RX_GPIO_NUM PIN_RX /* GPIO number for receiver */
#define RMT_CLK_DIV 100 /* RMT counter clock divider */
#define rmt_item32_tIMEOUT_US 9500 /*!< RMT receiver timeout value(us) */
#define RMT_TICK_10_US (80000000/RMT_CLK_DIV/100000) /* RMT counter value for 10 us.(Source clock is APB clock) */
#define ITEM_DURATION(d) ((d & 0x7fff)*10/RMT_TICK_10_US)
#define PIN_RX 22
static void rx_init()
{
rmt_config_t rmt_rx;
rmt_rx.channel = RMT_RX_CHANNEL;
rmt_rx.gpio_num = RMT_RX_GPIO_NUM;
rmt_rx.clk_div = RMT_CLK_DIV;
rmt_rx.mem_block_num = 30;
rmt_rx.rmt_mode = RMT_MODE_RX;
rmt_rx.rx_config.filter_en = false;
rmt_rx.rx_config.filter_ticks_thresh = 100;
rmt_rx.rx_config.idle_threshold = rmt_item32_tIMEOUT_US / 10 * (RMT_TICK_10_US);
rmt_config(&rmt_rx);
rmt_driver_install(rmt_rx.channel, 1000, 0);
}
Thanks