-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
5.5
Espressif SoC revision.
ESP32S3
Operating System used.
macOS
How did you build your project?
Other (please specify in More Information)
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32S3 Module dev
Power Supply used.
USB
What is the expected behavior?
the on_rx_down callback should be called, but it not
What is the actual behavior?
on_rx_down nerver has been called
Steps to reproduce.
I user esp32s3 module dev board , I use Arduino ice to program .
I connect twai rx to tx pin , then it could self-test.
the tx gpis has data to output , but the on_rx_done was not be called,
this is the code:
#include "esp_twai.h"
#include "esp_twai_onchip.h"
twai_node_handle_t node_hdl = NULL;
volatile int recv_ok = 0;
uint8_t recv_buff[80];
bool twai_rx_cb(twai_node_handle_t handle, const twai_rx_done_event_data_t *edata, void *user_ctx)
{
twai_frame_t rx_frame = {
.buffer = recv_buff,
.buffer_len = sizeof(recv_buff),
};
if (ESP_OK == twai_node_receive_from_isr(handle, &rx_frame)) {
// receive ok, do something here
Serial.println("recv one frame!");
recv_ok = 1;
return true;
}else {
Serial.println("recv failed!");
recv_ok = -1;
return false;
}
}
bool twai_err_cb(twai_node_handle_t handle, const twai_error_event_data_t *edata, void *user_ctx) {
Serial.print("edata val:");
Serial.println(edata->err_flags.val,HEX);
return true;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Initializing ...");
twai_onchip_node_config_t cfg = {
.io_cfg = {.tx = GPIO_NUM_16,
.rx = GPIO_NUM_17,
},
.bit_timing = {.bitrate = 250000,},
.tx_queue_depth = 5,
.flags = {.enable_self_test = 1},
};
ESP_ERROR_CHECK(twai_new_node_onchip(&cfg, &node_hdl));
// twai_timing_advanced_config_t timing_config = {
// .brp = 16, // prescaler w/ 80MHz clk. 80MHz/16 => 5 MHz => 200 ns per quanta
// // (80 MHz / 16)/(250 kHz) = number of quanta aka slices per bit = 20
// // so 20 = 1 + tseg1 + tseg2
// // to sample at 80% => 1 _ 15 _ _ 4
// .prop_seg = 2, // first part = prop_seg+tseg1
// .tseg_1 = 13,
// .tseg_2 = 4,
// .sjw = 3, // adjustable, allows the controller to adjust the bit timing (i.e. from clock drift)
// .triple_sampling = false,
// };
// ESP_ERROR_CHECK(twai_node_reconfig_timing(node_hdl, &timing_config, NULL));
twai_event_callbacks_t user_cbs = {
.on_rx_done = twai_rx_cb,
.on_error = twai_err_cb,
};
ESP_ERROR_CHECK(twai_node_register_event_callbacks(node_hdl, &user_cbs, NULL));
twai_mask_filter_config_t mfilter_cfg = {
.id = 0x00, // 0b 000 0001 0000
.mask = 0x00, // 0b 111 1111 0000 表示高7位严格匹配,低4位忽略,接收ID为
// 0b 000 0001 xxxx (16进制0x01x)
.is_ext = false, // 不接收扩展ID,只接收标准ID
};
ESP_ERROR_CHECK(twai_node_config_mask_filter(node_hdl, 0, &mfilter_cfg)); //配置过滤器0
ESP_ERROR_CHECK(twai_node_enable(node_hdl));
}
static uint8_t data[8] = {0x01,0x02,0x03,0xaa,0xaa,0xaa,0xaa,0xaa};
void loop() {
// put your main code here, to run repeatedly:
switch (recv_ok) {
case -1:
Serial.println("recv failed!");
recv_ok = 0;
break;
case 1:
Serial.println("recv success!");
recv_ok = 0;
break;
case 0:
Serial.println("recv not run!");
break;
}
twai_frame_t frame = {
.header={.id = 0x100,
.ide = false,
},
.buffer = data,
.buffer_len = sizeof(data)
};
ESP_ERROR_CHECK(twai_node_transmit(node_hdl, &frame, 0));
//Serial.println("A frame had sent!");
twai_node_status_t status;
twai_node_record_t sti;
twai_node_get_info(node_hdl , &status , &sti);
Serial.printf("tx_err_count:%d , rx_err_count:%d \n" , status.tx_error_count , status.rx_error_count);
delay(100);
}
Debug Logs.
Diagnostic report archive.
No response
More Information.
No response