I can't write to terminal window from called subroutine

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

This is just puzzling.  I am using Atmel Studio 7 with an Arduino Uno.  I want to display data on the terminal window.  It works just fine as long as the STS UDR0, R20 command is in the main line of processing.  If I put that command into a called subroutine, the terminal display fills with the first character, repeated over and over.  I can code the same thing over and over if needed, but it is irritating.  Yes, I am coding in Assembler.  I am using lines copied from the Atmega 328p datasheet.  I am setting the UBRR0 to 00:67 hex.  That is a little bit of Kentucky windage there.  The manual had suggested 66 for an mpu running at 11.8 mhz.  The Uno has a 12 mhz crystal.

 

As I say, it works just fine as long as all my writes to terminal happen in the main portion of the program.  

 

Suggestions?  Comments?  Questions

This topic has a solution.

I'm serious about pinball. Everything else is just for fun.

Last Edited: Mon. Oct 19, 2020 - 12:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps... show the code? Show the subroutine and how it is called.

/Jakob Selbing

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

You must wait for the UART to be ready to accept the next character---are you monitoring the status bit before trying to send each character?

There's really not much to the whole thing, so you are prob making some simple code mistake...show a copy.

Also some terminals can get overloaded (can't keep up), depending on baudrate, PC settings, etc.  So you may want to put some delay between characters, a few ms is plenty.   Bray's  terminal 

will goof up if you give it a long blast of characters without rest.  See, computers get tired too.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Oct 18, 2020 - 08:07 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mark this one closed.  I still don't know what I was doing wrong.  I opened up a new program with just the code to access the terminal window as a called subroutine.  With just that code in place, the program ran perfectly.   I had left out a call to a routine that read from EEPROM that had been in the program.  I do not know if that was the conflict or not   

 

Anyway, all is well that ends well.

 

Thanks for your responses. 

I'm serious about pinball. Everything else is just for fun.

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

Pinworks wrote:
Mark this one closed

You do that by marking the solution - see Tip #5 in my signature, below, for instructions:

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

Thank you.  I think it is marked.  I clicked on the mark button and now it says 'unmark.'

I'm serious about pinball. Everything else is just for fun.