View previous topic :: View next topic |
Author |
Message |
tranz
Joined: 10 Feb 2007 Posts: 78
|
Making a 18f4620 work like a hyperterminal on echo mode. |
Posted: Tue Sep 30, 2008 5:46 pm |
|
|
Hi,
I am working with an 18f4620, and I am trying to use its serial port to send data to another embedded system. But I would also like to see the data come back. Similar to the hyperterminal working in echo mode.
I will be seeing the data on the LCD which is connected to another pic which is connected the the 18f4620 using USART.
Thanks
Tranz |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
tranz
Joined: 10 Feb 2007 Posts: 78
|
|
Posted: Wed Oct 01, 2008 12:24 pm |
|
|
Thanks PCM !
But if I want to create a response from the micro (18F4620) based on a sentence given by the user, how would I get to do it.
Like if I would like to give a response for
"Would you like to clear the eeprom (y or n) : " and I want the micro to give the response of "y", how do i get to do that. The present program that I am running only takes in characters.
the present code looks something like this..
Code: |
void ui_handle(void)
{
char c;
c=fgetc(USER);
c=toupper(c);
switch(c) {
case 'T': hardware_test();
break;
case 'D': ui_settings();
//delay_ms(3000);
break;
case 'S': ui_setup();
break;
case 'Z': clear_ee();
fprintf(USER,"\r\nEEPROM Cleared\r\n");
break;
}}
void main(void) {
init();
splash();
while (TRUE) {
if (kbhit(USER))
{
ui_handle();
}
}
}
|
USER is the steam for the serial communication and in this case I am using the hardware pins. |
|
|
tranz
Joined: 10 Feb 2007 Posts: 78
|
|
Posted: Wed Oct 01, 2008 1:45 pm |
|
|
I know fgets would be the best solution for this problem, but when I put it with a stream its showing compiling errors.
Code: |
void ui_handle(void)
{
char c[30];
char h;
printf("Type 'a' to relock baud-rate: ");
printf("Erase FLASH? (y/n): ");
c=fgets(USER);
if (strcmp(c,Type 'a' to relock baud-rate:))
{
fprintf(USER,"a");
}
if (strcmp(c,Erase FLASH? (y/n):))
{
frpintf(USER,"y");
}
}
|
|
|
|
|