Postby reypowerlu » Wed Feb 23, 2022 8:11 am
目前使用ESP32-C3-S32芯片的TWAI功能,使用例程测试GPIO2/GPIO3引脚是否输出时,出现IO无数据波形的情况,请问有人知道是什么问题吗?
void app_main(void)
{
twai_message_t message;
//Initialize configuration structures using macro initializers
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
//Install TWAI driver
if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG, "Driver installed\n");
}
else
{
ESP_LOGI(EXAMPLE_TAG, "Failed to install driver\n");
return;
}
//Start TWAI driver
if (twai_start() == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG, "Driver started\n");
}
else
{
ESP_LOGI(EXAMPLE_TAG, "Failed to start driver\n");
return;
}
message.identifier = 0xAAAA;
message.extd = 1;
message.data_length_code = 8;
for (int i = 0; i < 8; i++)
{
message.data[i] = 0x0A;
}
while(1)
{
//Queue message for transmission
if (twai_transmit(&message, pdMS_TO_TICKS(10000)) == ESP_OK)
{
ESP_LOGI(EXAMPLE_TAG,"Message queued for transmission\n");
}
else
{
ESP_LOGI(EXAMPLE_TAG,"Failed to queue message for transmission\n");
}
vTaskDelay(pdMS_TO_TICKS(10000));
}
vTaskDelete(NULL);
}
-
Attachments
-
- log
- 屏幕截图 2022-02-23 161040.jpg (213.67 KiB) Viewed 1142 times