AS 7 and UART library (by Craig Hollinger)

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

Hi. Using AS7 and an Arduino (Uno), I want to use the USB serial connection.  I can get the version working of Craig Hollinger (thank you Craig, from Github), but I have an issue.

 

My current issue is that the function uart_getchar() seems deficient.  If I throttle the port with say 10 characters from PC (Realterm SW), I only get the first 2 characters before an Overflow error occurs.  I, of course, want all characters.

 

Is there a fix for this kind of issue ??

Possibly a different suitable library ??

What about HW flow control ??   or   What about SW buffering ??

 

I have the Arduino IDE version working OK and also the import of the same into AS7 (and OK).  However, I interested in getting the simple library to work.

 

Regards JC.....

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

You mean this:  https://github.com/hollingerc/AVR  ?

 

Have you tried raising an issue with the author on Github ?

 

jmclifford@aanet.com.au wrote:
I interested in getting the simple library to work

It's conceivable that "the simple library" would not include "extras" like buffering, flow control, etc ... ?

 

Have you looked at your other code to see how this is handled there ?

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 wrote:
It's conceivable that "the simple library" would not include "extras" like buffering, flow control, etc ... ?

Which does seem to be what the code says:

Craig, from Github, wrote:

 * These are very basic functions, the send and receive functions block until
 * the character is sent or received.  At the very least, they will waste CPU
 * time if the BAUD rate is low or a lot of data is being sent.  At the the
 * worst, they could block indefinitely if something goes wrong. 

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...
Last Edited: Mon. Mar 9, 2020 - 09:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is the strangest UART library code I have ever seen! Often folks will chose to do both Tx and Rx synchronously because it is the easiest to implement, other times they might choose to do it asynchronously (interrupts). If they want a "mix of both" then a very common thing is to implement the transmission as the simple synchronous/polled solution (as the AVR is in charge of when it wants to send things) but to implement the receive as an ISR() because your AVR program cannot know when the "other end" might start to send characters so you implement a receive interrupt and each time a character arrives it just interrupts current work (as long as you don't make the mistake of keeping interrupts disabled) and it puts it in a buffer, then later the AVR can pick them out when it has time to "catch up".

 

But that weird code has chosen to do TX with ISR() but the RX seems to be polled. This is the "wrong way round" if you are only doing ISR on one side. Now, if the AVR is "tied up" and the other end (PC) starts to send a burst of characters it's not in the right place to catch them all.

 

If you don't fancy writing UART code yourself can I suggest you switch your sights to Peter Fleury's UART library on this page:  http://www.peterfleury.epizy.com/avr-software.html?i=1 ? That does ISR-RX.

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

So whats wrong with the Arduino USART functions?   They work.....

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Hi.  This is a late response, but thank you clawson.

The Peter Fleury's libraries ( UART and TWI ) seem to be excellent.

The UART library permits buffering in both directions.  Also, I suspect that data can be sent to the PC (from Arduino) while the Arduino mainline performs TWI/I2C comms with an EEPROM.  That is overlaying communication operations.

 

I will have another question on this in another thread/posting.

 

Regards JC.......

 

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

jmclifford@aanet.com.au wrote:
I will have another question on this in another thread/posting.

Don't keep us guessing - give the link!

 

https://www.avrfreaks.net/forum/pete-fluerys-uart-library-spare-buffer-space

 

And, if this thread is now resolved, please mark the solution - see Tip #5 in my signature, below:

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...