• AVR Freaks

Hot!USART RX/TX Enable Pin via Register Empty Interrupt (DRE)

Author
photonthunder
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2020/10/06 12:09:09
  • Location: 0
  • Status: offline
2020/10/12 08:19:04 (permalink)
0

USART RX/TX Enable Pin via Register Empty Interrupt (DRE)

I have a RS485 signal that comes in and is converted to TTL USART and feed into my ATSAMD51 processor.  I used Harmony to create my lib_sercomX_usart.c file and I added to the SERCOMX_USART_ISR_TX_Handler a digital IO line that puts the RX485 back into RX mode after transmission.  Since my signal is sent at 9600 baud I find that I get the interrupt handler before the last byte has completed and thus I have to add a delay to get it to work.  
 
Is there any other interrupt, other then DRE, that I can set that would work for telling me when the last byte has actually been sent? 
#1
vgandhi
Senior Member
  • Total Posts : 52
  • Reward points : 0
  • Joined: 2016/10/24 21:28:35
  • Location: 0
  • Status: offline
Re: USART RX/TX Enable Pin via Register Empty Interrupt (DRE) 2020/10/13 09:50:08 (permalink)
0
After copying the last byte into the DATA register, you may want to enable TXC interrupt which is generated when both the Data and Shift registers are empty. Since there is nothing left to transmit, you will have to disable TXC interrupt after it is generated to avoid getting interrupted again and again.
#2
photonthunder
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2020/10/06 12:09:09
  • Location: 0
  • Status: offline
Re: USART RX/TX Enable Pin via Register Empty Interrupt (DRE) 2020/10/13 10:09:16 (permalink)
0
@vgandhi, thank you. I think that will work.  Is there any way to implement that within Harmony or is the best approach just to make the modifications in the lib_sercomX_usart.c file and then merge the changes each time I change my harmony XML file?
#3
vgandhi
Senior Member
  • Total Posts : 52
  • Reward points : 0
  • Joined: 2016/10/24 21:28:35
  • Location: 0
  • Status: offline
Re: USART RX/TX Enable Pin via Register Empty Interrupt (DRE) 2020/10/13 10:38:48 (permalink)
0
If you want the changes to be generated through Harmony, then you will need to modify the corresponding FTL file available under <harmony-install-path>\csp\peripheral\sercom_u2201\templates\plib_sercom_usart.c.ftl (OR plib_sercom_usart_ring_buffer.c.ftl if ring buffer mode is enabled).
#4
Jump to:
© 2020 APG vNext Commercial Version 4.5