|
|
View previous topic :: View next topic |
Author |
Message |
gadylio
Joined: 29 Mar 2011 Posts: 1
|
pic16f877a through rs232 using max232, garbage is out |
Posted: Tue Mar 29, 2011 2:31 pm |
|
|
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
|
|
Posted: Tue Mar 29, 2011 3:29 pm |
|
|
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. |
|
|
|
|
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
|