ATMega1284 and HyperTerminal

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

Hey guys,

So i have been stuck on this for a few days now and I just cannot seem to figure it out. I am trying to do something that I believe is simple however I have had nothing but issues since the beginning. I setup my micro to recieved a character from my keyboard and then display that same character in hyperterminal. This part works great! however when I try to just send that same character from the micro (without reading it from the key board) all I get is "FF" or nothing at all. Here is my code:

#define F_CPU 16000000UL
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

#include 



int main(void)
{
int RecievedByte;
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
UCSR0C = ~(1<<USBS0) | (1<<UCSZ00) | (1<<UCSZ01) | ~(1<<UCSZ02);
UBRR0H = (BAUD_PRESCALE >> 8);
UBRR0L = BAUD_PRESCALE; 
    while(1)
    {
		
    RecievedByte = 0x41;
    //while ((UCSR0A & (1 << UDRE0)) == 0) {}; 
    //RecievedByte = UDR0;
    while ((UCSR0A & (1 << UDRE0)) == 0) {};
    UDR0 = RecievedByte;  
    _delay_ms(200);
    }
}

Any ideas? I know I am missing something...

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

Irwinjs22 wrote:

I setup my micro to recieved a character from my keyboard and then display that same character in hyperterminal.

How have you proved that this is working correctly and is not just a wiring fault with TX and RX shorted together?

If you haven't, try altering your code that you think runs correctly and get it to add 1 to every character received before echoing it back.

And check that Hyperterminal isn't set to echo characters.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Delete this line, apart from being messy it's not necessary.

UCSR0C = ~(1<<USBS0) | (1<<UCSZ00) | (1<<UCSZ01) | ~(1<<UCSZ02); 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

If your controller's USART is not actually receiving a character from HyperTerminal and the internal HyperTerminal echo is enabled, it would give all the appearance that you are receiving a character and re-transmitting but, in fact, you really aren't.

Have you made sure that the character you are sending from HyperTerminal is actually being received by your controller and that you don't have HyperTerminal's internal echo enabled?

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Quote:
How have you proved that this is working correctly and is not just a wiring fault with TX and RX shorted together?

I am using a MAX232 to com 4 on my PC and I set my code up to receive a char from Hyperteminal. The micro receives the character and sends it back to hyperterminal in which case when I press "Shift a" hyper terminal receives "A". I have also scoped the TX line to verify this and I can clearly see "01000001" from the micro to the max232 and "10111110" from the Max232 to the PC. Scoping the lines when sending raw 0x41 I see "0000010" from the micro to the max232 and the same signal inverted from the max232 to the micro.

Quote:
Delete this line, apart from being messy it's not necessary.

Thanks fro advice.

Quote:
If your controller's USART is not actually receiving a character from HyperTerminal and the internal HyperTerminal echo is enabled, it would give all the appearance that you are receiving a character and re-transmitting but, in fact, you really aren't.

This is not the case, echo is turned off in hyperterminal.

I recently tried using relaterm instead of hyperterminal and it says I am receiving "FF". If I send 0x41 to hyperterminal does it see that value as ASCII "A"?

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

Quote:
Delete this line, apart from being messy it's not necessary.

This actually fixed my issue! I will look into this more to understand what i did to cause this issue. I have spend 3 days on this and now I feel pretty silly, Thanks!!!

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

Irwinjs22 wrote:
Quote:
Delete this line, apart from being messy it's not necessary.

This actually fixed my issue! I will look into this more to understand what i did to cause this issue. I have spend 3 days on this and now I feel pretty silly, Thanks!!!

Compared to some of my silliness where I've spent weeks missing the point, I'd say you got off pretty easy.

Chalk it up to the learning curve.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

Did you expect the ~ to clear the bit? Well it does but coupled with the | meant it set the other bits. This was probably not what you wanted. It helps to be solid with your and, or & not operations with embedded stuff.