RMT interrupts

rocketstrong
Posts: 1
Joined: Sat Sep 08, 2018 5:12 pm

RMT interrupts

Postby rocketstrong » Sat Sep 08, 2018 5:19 pm

I have Been using the RMT driver and have been able to get it to work however i'm stuck getting an interrupt when RX received.

in the documentation https://docs.espressif.com/projects/esp ... interrupts it says
When calling rmt_driver_install() to use the system RMT driver, a default ISR is being installed. In such a case you cannot register a generic ISR handler with rmt_isr_register().
this confuses me.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: RMT interrupts

Postby ESP_Sprite » Sun Sep 09, 2018 5:33 am

The trick is that you can either program the RMT yourself, by hooking the receive interrupt, setting options yourself and taking care of the communication with the rest of the program, or you can have the RMT driver hook into the interrupt and make use of the blocking threadsafe API it offers. The choice is yours, but you can't have both.

Markus391
Posts: 6
Joined: Sat Oct 13, 2018 11:56 am

Re: RMT interrupts

Postby Markus391 » Sun Oct 14, 2018 8:25 am

Hmm, yes, that makes sense. I assume that in this case you will use

Code: Select all

rmt_set_rx_intr_en( config.channel,true);
 rmt_isr_register(rmt_isr_handler, NULL, ESP_INTR_FLAG_LEVEL1, &xHandler);

Instead of: 
rmt_driver_install(config.channel, 100, 0)): 
By this I managed to hook the interrupt and disable the ringbuffer. But how to get the data? I tried as follows, but only the initial value was received, but it seems that I never I get data updates?

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;
}
Pls also refer to my thread for more details:
viewtopic.php?f=13&t=7646

With the Standard ISR and the ringbuffer in place I was able to get data from the items provided by the ringbuffer successfully. But then it seems to be necessary to prevent the buffer getting full by a separate task. But in my case i want to use this to get (PWM) pulses data from a radio reveiver to control a drone. So I just need the latest integer anyway.

Would be great, if anybody could help me out ...Thank you so much.....

Markus391
Posts: 6
Joined: Sat Oct 13, 2018 11:56 am

Re: RMT interrupts

Postby Markus391 » Wed Oct 17, 2018 9:08 am

I'm still investigating to get my own RMT interrupt running. At the moment I'm worrying, if rx_en is really enabled with my code above and if I'm really accessing to the correct memory address (RMT_MEM_PD)?? Would be happy to find someone who has some experience with it... Thx
Attachments
IMG_20181015_075757_531.jpg
IMG_20181015_075757_531.jpg (130.15 KiB) Viewed 10574 times

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RMT interrupts

Postby WiFive » Wed Oct 17, 2018 9:58 am


Markus391
Posts: 6
Joined: Sat Oct 13, 2018 11:56 am

Re: RMT interrupts

Postby Markus391 » Wed Oct 17, 2018 10:19 am

Thanks for letting me know....Seems like I'm on the correct way. But why no data? I will next try to unset the enable bit and ownership. Looking forward what happens.....Thx again

Markus391
Posts: 6
Joined: Sat Oct 13, 2018 11:56 am

Re: RMT interrupts

Postby Markus391 » Wed Oct 17, 2018 6:13 pm

Wow, actually it succeeded as follow..With the following interrupt routine I was able to get data for channel 0:

Code: Select all

void IRAM_ATTR rmt_isr_handler(void* arg){
  //read RMT interrupt status.
  uint32_t intr_st = RMT.int_st.val;

  RMT.conf_ch[0].conf1.rx_en = 0;
  RMT.conf_ch[0].conf1.mem_owner = RMT_MEM_OWNER_TX;
  volatile rmt_item32_t* item = RMTMEM.chan[0].data32;
  if (item) Serial.print ((item)->duration0);
  
  RMT.conf_ch[0].conf1.mem_wr_rst = 1;
  RMT.conf_ch[0].conf1.mem_owner = RMT_MEM_OWNER_RX;
  RMT.conf_ch[0].conf1.rx_en = 1;

  //clear RMT interrupt status.
  RMT.int_clr.val = intr_st;
}
Thank you so much again.....

Who is online

Users browsing this forum: Bing [Bot], Corand and 100 guests