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

PIC18F452 UART

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



Joined: 05 Dec 2004
Posts: 31

View user's profile Send private message

PIC18F452 UART
PostPosted: Wed May 15, 2019 5:52 am     Reply with quote

In the follow codes, ascii value 1.23 is send to pic18f452 via uart. How to modify the code in order to make some judgement in ascii value ?
Code:
#include <18f452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NODEBUG
#use delay(clock=20000000)
#use RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)

int8 j;

void main(){
                      // Set internal oscillator to 8MHz
  while(TRUE){
    if(kbhit()){    // If a character available
      j = getc();   // UART read
      putc(j);      // Send it back
    }
}
}



like if (j=='1.23'), this show error !!
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Wed May 15, 2019 6:07 am     Reply with quote

Look up the atoi(), atof(), and atol() functions in the manual. They turn null terminated strings into numbers that will allow you to do what you want.

They are not specific to ccs, so you can just Google them as well.
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