Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

transmit numbers thru usart

Not open for further replies.


Junior Member level 1
Jan 24, 2006
Reaction score
Trophy points
Activity points
i need a c program that transmits the number 1 to 20 from the hardware to the PC hyperterminal thru USART...My hardware is PICDEM PLUS 2 from microchip...and i'm using mplab ide to write this program..any help will be greatly appreciated...:

Hello, i can't give you the code but i think i can point you in the right direction.
You can only transmit 8 bits at a time, this makes a byte so to transmit a number equal to or larger than 10 you'll need to transmit two bytes (or two chars).
The number from 0 to 9 are represented in the ascii table with the numbers 48 to 57 (decimal) so that mean they are represented from 30 to 39 (hexadecimal) so you need to send through the usart 30h to send a zero, 31h to send an one 32h to send a two, and so on. to send 10 you'll need to send 31h and then 30h.
I hope this helps you understand the concept. with this knowledge you can then send anything you want, text numbers and other chars.
If i'm not wrong Ah is the carriage return, you'll need it to make numbers print in a new line.

thanks rookie...i get what u mean,but how do i define before using ascii,is there any special definitions...?like int,char or etc...

Hi Asham,

You should define the byte you sending as an Unsigned char.

the asci table dec values are starting at 0x00, and the char variable type is from -128 to 127. the unsigned char is from 0 to 255 : therefor this type will cover all the asci table characters.

Good luck,


when transmitting numbers u have to send ascii value of that number
so add 0x30 with your number
for example for 1 u need to send as 0x31


Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to