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

pic16f877a through rs232 using max232, garbage is out

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



Joined: 29 Mar 2011
Posts: 1

View user's profile Send private message

pic16f877a through rs232 using max232, garbage is out
PostPosted: Tue Mar 29, 2011 2:31 pm     Reply with quote

my code is
Code:

#include <16F877A.h>
#FUSES XT, NOWDT, NOPROTECT
#USE DELAY(CLOCK = 4000000)
//Hardware UART : TX is RC6, RX is RC7
#USE RS232(baud = 9600, xmit = PIN_C6, rcv = PIN_C7)
//Define inline functions: isupper() and islower()
//isAmong(): checks if the character is in the character list, if so return true else false.

char temp[20];
char x[20];

void main()
{

//======================================
 
strcpy(temp, "kitchen"); // Copy const string into ram array

// Now you can use strcmp() to compare temp to another array.
// Put your strcmp() code here.

output_high(pin_b7);
delay_ms(500);
output_low(pin_b7);
delay_ms(500);
delay_ms(2000);
printf("kitchen\n");//
delay_ms(2000);
printf("bath\n");
delay_ms(2000);
printf("gad5ra\n");
delay_ms(2000);
printf("2skot\n");

while(1)
{
gets(x); //getc() is used for receiving one character from PC.

if(strcmp(temp,x))
{
output_high(pin_b7);
delay_ms(2000);
}
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 29, 2011 3:29 pm     Reply with quote

Quote:
if(strcmp(temp,x))
{
output_high(pin_b7);
delay_ms(2000);
}
}
}

strcmp() returns 0 if the strings match. So, if string 'x' matches string
'temp', the code above will NOT execute. Pin B7 will not go high.
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