Problems with Teraterm and USART[mega8]

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

I have been experimenting with the USART on an AtMega8, and after two days of frustration and swearing and sweating I managed to send a repeated sequence of two characters to my pc [using C and writing directly the registers].

Next step was to make my own putchar and putstring functions, since I needed a simple way to get data to terminal without the overheads of using printf. Putchar seems to work ok. Using putstring I managed to send something to TeraTerm, but the data is not legible [lots of unprintable characters/symbols].

Now for the funny part:
When I copy the data from TeraTerm to Notepad, the text is legible!!!

What could be happening? Could this be a software issue with teraterm? Could I be making a mistake in calling putchar from putstring?

Here is the code:

static volatile uint8_t tx_complete = 255;
uint8_t putchar_uart (char char_out)
{
	if (tx_complete == 255)//If
	{
		tx_complete = 0;//Clear my own flag
		UCSRA &= 0b10111111;//Clear end of transmission flag
		UDR = (int)char_out;//Send data
        UCSRB |= 0b00001000;//Trigger transmission
        UCSRB &= 0b11110111;//De-trigger transmission
        return 0;
	}
	else
	{
		return 255;
	}
}

uint8_t putstring_uart (char *string_out)
{
uint8_t i = 255, j = 0;
char k;

	do
	{
	    do
	    {
	        k = *(string_out + j);
//Copy data from string to temporary char
	        i = putchar_uart(k);
//print char to uart.
		}
	    while(i != 0);
//Wait until character has been transmitted
		j++;
//increment counter
	}while ((*(string_out+j-1) != '\0'));
	return 0;
}

ISR (USART_TXC_vect)
{
extern uint8_t tx_complete;
//Set the global flag variable to show we have just completed a transmission.
	tx_complete = 255;
}
[\code]

To the C-gurus out there, should passing the parameters to the function by reference make any difference between the two ways of calling putstring_uart below?

putstring_uart("killed by the C");

char temp[20] = "killed by the C";
putstring_uart(temp);

[/code]

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

Ok, problem solved!
The offender was teraterm. A good system re-boot and it behaves ok!

sorry for disturbing!
:)
nxp

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

sounds like you got one of the "switch terminal to graphical character set" sequences. On some terminals, it's not uncommon to have this happen, and need to reset the terminal into regular character mode.

i think generally this is caused by displaying ascii 14 (ctrl-N); you can reset with ascii 15 (ctrl-O). See http://www.in-ulm.de/~mascheck/v... for a more comprehensive explanation (note their recommendations are for commands through a UNIX shell though)