ESP32-C3-S32的TWAI问题

reypowerlu
Posts: 3
Joined: Wed Feb 23, 2022 8:05 am

ESP32-C3-S32的TWAI问题

Postby reypowerlu » Wed Feb 23, 2022 8:11 am

  1. 目前使用ESP32-C3-S32芯片的TWAI功能,使用例程测试GPIO2/GPIO3引脚是否输出时,出现IO无数据波形的情况,请问有人知道是什么问题吗?
  1. void app_main(void)
  2. {
  3.     twai_message_t message;
  4.  
  5.     //Initialize configuration structures using macro initializers
  6.     twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TX_GPIO_NUM, RX_GPIO_NUM, TWAI_MODE_NORMAL);
  7.     twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS();
  8.     twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
  9.  
  10.     //Install TWAI driver
  11.     if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK)
  12.     {
  13.         ESP_LOGI(EXAMPLE_TAG, "Driver installed\n");
  14.     }
  15.     else
  16.     {
  17.         ESP_LOGI(EXAMPLE_TAG, "Failed to install driver\n");
  18.         return;
  19.     }
  20.  
  21.     //Start TWAI driver
  22.     if (twai_start() == ESP_OK)
  23.     {
  24.         ESP_LOGI(EXAMPLE_TAG, "Driver started\n");
  25.     }
  26.     else
  27.     {
  28.         ESP_LOGI(EXAMPLE_TAG, "Failed to start driver\n");
  29.         return;
  30.     }
  31.  
  32.     message.identifier = 0xAAAA;
  33.     message.extd = 1;
  34.     message.data_length_code = 8;
  35.     for (int i = 0; i < 8; i++)
  36.     {
  37.         message.data[i] = 0x0A;
  38.     }
  39.  
  40.     while(1)
  41.     {
  42.         //Queue message for transmission
  43.         if (twai_transmit(&message, pdMS_TO_TICKS(10000)) == ESP_OK)
  44.         {
  45.             ESP_LOGI(EXAMPLE_TAG,"Message queued for transmission\n");
  46.         }
  47.         else
  48.         {
  49.             ESP_LOGI(EXAMPLE_TAG,"Failed to queue message for transmission\n");
  50.         }
  51.        
  52.         vTaskDelay(pdMS_TO_TICKS(10000));
  53.     }
  54.     vTaskDelete(NULL);
  55. }
Attachments
屏幕截图 2022-02-23 161040.jpg
log
屏幕截图 2022-02-23 161040.jpg (213.67 KiB) Viewed 1141 times

Who is online

Users browsing this forum: No registered users and 52 guests