How can I write directly to USART registers with ASF4

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using a SAMV71 with ASF4. I want to set it up for RS485 mode with hardware support for Drive Enable using the RTS special function. I can’t find a way to do this using the ASF API. The only RS485 example I can find is from Atmel  Studio using deprecated  include files.

 

How can I write directly to the registers of the USART using ASF4 low level  functions? 

What is the correct (supported) way to do this?

 

I need to write to US_MR and to US_TIGR register to set the timeguard.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you're writing directly to registers, ASF is irrelevant!

CpuDude wrote:
What is the correct (supported) way to do this?

ASF assumes that it has control of the registers.

 

If you are also using ASF, it's just up to you to make sure that you don't mess-up anything that ASF is relying upon.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@awneil. Thanks for the reply. I kind of figured that was the case. I was hoping that there was something I missed in the documentation and that someone might say, they already support RS485 if you use function XXXX . Or you can write to the registers using ASF low level function XXXX.   I am trying to stay within ASF4 as much as possible to make it easier to upgrade my firmware when they get around to updating ASF4.

 

But alas, it looks like I just need to brute force it myself. 

 

There are some functions in "hri_usart_v71b.h" that write to the USART registers.  Perhaps I can use those.  Or maybe it is better to write my own, since if they are not supporting the use of those functions (as in they are not documented in the ASF4 reference manual), they may disappear in future ASF4 release.