View previous topic :: View next topic |
Author |
Message |
lgeorge123
Joined: 05 Dec 2004 Posts: 31
|
PIC18F452 UART |
Posted: Wed May 15, 2019 5:52 am |
|
|
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
|
|
Posted: Wed May 15, 2019 6:07 am |
|
|
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. |
|
|
|
|
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
|