UART Issue Sending Hex Value

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

Hey guys i have been trying to send HEX values through the usart but am not receiving them. I can send numbers and strings no issues.

I am using Peter Fluerys usart library. I am trying to Send 0x7E, but i receive FE FF in my terminal viewer.. What am I missing? oh currently using using an arduino mega to send data so its running at 16MHZ with a baud rate of 9600

 

int main(void)
{
	DDRB |= (1 << PB7);
	PORTB &= ~(1 << PB7);
	uart_init(9600);
	uint8_t data = 0x7E;
		
    /* Replace with your application code */
    while (1) 
    {
		PORTB ^= (1 << PB7);
		while(!(UCSR0A & (1 << UDRE0)));
		UDR0 = data;
		_delay_ms(1000);
		
    }
}

 

 

This topic has a solution.
Last Edited: Wed. Sep 25, 2019 - 11:59 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if you send 0x41 does that print 'A'? Sounds like a baud rate problem, but you say you can print numbers and strings. How do you do this?

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

you were right, i wasn't setting up the uart properly...i sent the text and numbers in a different solution..

 

I had

uart_init(9600);

when it is supposed to be

 

uart_init(UART_BAUD_SELECT(9600, F_CPU));

Thanks