Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ASCII

Status
Not open for further replies.

YAN-1

New Member
Hi. I am using a 16F877 to communicate with an electronic compass. This is done through the UART port. In the datasheets of the compass, it says that I have to send it commands in ASCII form in order to have it execute several things. For example, if i send it *S<cr><lf>, then it starts/stops transmitting data. All of the commands are in the form of:
*X<cr><lf>, where X could be any letter.

Now my problem is that I am not sure how to send these things! I know how to operate the UART port and how to send bytes but, in this case, do I have to send 4 successive bytes (the '*', the 'S', the <cr>, and the <lf>)?? And if yes, how do I do that? I mean do I look for their ASCII codes and send them as integers or do I define a variable of type 'char' and do something like:
char data;
data = '*';
TXREG = data;

??

Please help. Thanks a lot.
 
Ascii Data

Just send ascii characters. You can look them up in a table.

For example:

*S<cr><lf> becomes 0x2A, 0x53, 0x0D, 0x0A

Send this sequence of values (written above in hex).
 
Status
Not open for further replies.

Latest threads

Back
Top