CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need little help in RS 232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

Need little help in RS 232
PostPosted: Thu Mar 06, 2008 10:25 pm     Reply with quote

i am making a simple program for PIC 16F877 that can read characters serially (RS-232) from computer. then convert that character to integer so that i can make arithmetic modification (e.g multiply it with 5) and then echo or send it back to computer.

I am having difficulty in converting character to integer (i dont know the built in function). I am new to CCS. Please help me.......... Confused
Guest_7068
Guest







PostPosted: Thu Mar 06, 2008 10:58 pm     Reply with quote

Use example Ex_Sisr.c to read characters serially into a buffer and then convert the string into a number using one of the following functions.

Code:

#include <stdlib.h>

ivalue = atoi(string)  // Returns 8 bit int  >> Max String Length = 3

lvalue = atol(string)  // Returns 16 bit value >> Max String Length = 5

i32value = atoi32(string)  // Returns 32 bit value  >> Max String Length = 9

SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Mar 07, 2008 9:23 am     Reply with quote

If the character contains a binary number, just cast the byte from one type to the other. Casting is a standard C term that any C book will cover.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group