Page 1 of 1

RMT - simplest receive example with Custom Interrupt

Posted: Sat Oct 13, 2018 12:07 pm
by Markus391
Im trying to implement an RMT Receiver at RMT channel 0 with my own interrupt. The interrupt is already fired successfully, but inside the interrupt, I can not get the correct data. This is how my interrupt is coded:

Code: Select all

rmt_isr_handle_t xHandler = NULL; 
void IRAM_ATTR rmt_isr_handler(void* arg){
   //read RMT interrupt status.
   uint32_t intr_st = RMT.int_st.val;
 
   rmt_config_t config;
   config.channel = (rmt_channel_t) 0;
   volatile rmt_item32_t* item = RMTMEM.chan[config.channel].data32;
   // In the following lineI would expect to get the ticks counted, but I doesnt seem to work
   // Some data is printed out, so the item seems to be exisi, but its value will never get refreshed....
   if (item) Serial.print ((item)->duration0);	

    Serial.println();  

  //clear RMT interrupt status.
  RMT.int_clr.val = intr_st;
}
This is the initialization:

Code: Select all

void ESP32_Receiver::init(int pin, int channel) {
  _pin = pin;
  _channel = channel;

  rmt_config_t config;
  config.rmt_mode = RMT_MODE_RX;
  config.channel = (rmt_channel_t) _channel;
  config.gpio_num = (gpio_num_t)pin;
  config.mem_block_num = 1;                 //how many memory blocks 64 x N (0-7)
  config.rx_config.filter_en = true;
  config.rx_config.filter_ticks_thresh = 100;
  config.rx_config.idle_threshold = 9500;
  config.clk_div = 80; //1MHz
  ESP_ERROR_CHECK(rmt_config(&config));
  rmt_set_rx_intr_en( config.channel,true);
  rmt_isr_register(rmt_isr_handler, NULL, ESP_INTR_FLAG_LEVEL1, &xHandler);
  //ESP_ERROR_CHECK(rmt_driver_install(config.channel, 100, 0));
  rmt_rx_start(config.channel, 1);
}
Would be great, if anybody has an idea to figure it out. Thk you so much....