transmit unsigned short value through USART

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

i AM WRITING CODE to write into eeprom.After that i want to find how many bytes leftover in eeprom.
I want to trasmit the leftover bytes to my hyperterminal.How to transmit the unsigned short through usart?Any help.

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

Put the value in the UART data register (after configuring the UART to send data at a desired baud rate) AND after connecting a logic-RS232 converter and a DB9 connector).

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

The unsigned short consists of two bytes. You could split this into two bytes and send them, but how does the receiving end know if they are properly aligned? There's two main choices here:
either send it as numbers
or wrap the data in a packet that frames the data.

Sending it as numbers is a simple as

printf("EEprom bytes left %d\r\n",eeprom_bytes);