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

receive ASCII string and convert to int

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 20, 2008 3:01 pm     Reply with quote

You didn't post the #include, #fuses, #use delay(), or #use rs232()
statements. Also, you don't need to copy and paste the get_string()
function. Just #include the input.c file. Here's a test program.
Make a program similar to this and see if you can type in a string
in a terminal program on your PC, and get the PIC to receive it
and send it back to the PC.
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <input.c>

//======================================
void main()
{
char temp[10];

printf("Enter string: ");

get_string(temp, sizeof(temp));

printf("\n\rReceived: %s \n\r", temp);

while(1);
}
coderchick



Joined: 12 Jun 2008
Posts: 25

View user's profile Send private message

PostPosted: Thu Nov 20, 2008 8:12 pm     Reply with quote

Code:
#include <stdlib.h>
#include <input.c>
#include <16F887.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz for PCM/PCH
#FUSES PUT                      //Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPD                    //No EE protection
#FUSES NOBROWNOUT               //No brownout reset
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOLVP                    //No low voltage prgming,
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOWRT                    //Program memory not write protected
#FUSES BORV40                   //Brownout reset at 4.0V

#use delay(clock=4000000)
#use rs232(baud=57600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


Quote:

Make a program similar to this and see if you can type in a string
in a terminal program on your PC


Using that program I was able to communicate with my PIC through the terminal with no problems. I can also use the terminal to communicate with the driver, however, I still can't combine the two. Now what? The terminal program proves that my code can potentially use the get_string function, and I've been able to prove that I can talk to the driver through the terminal, so now, how do I subtract the terminal and get the two boards talking to each other?
_________________
KMoe

~We the willing, led by the unknowing, are doing the impossible for the ungrateful. We have done so much, for so long, with so little. We are now qualified to do anything with nothing -M. Theresa
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 20, 2008 8:43 pm     Reply with quote

get_string() expects a carriage return to mark the end of a string.
Do you have a '\r' escape sequence at the end of your strings
in your Master PIC code ? Example:
Code:
printf("Hello\r");
coderchick



Joined: 12 Jun 2008
Posts: 25

View user's profile Send private message

PostPosted: Fri Nov 21, 2008 6:56 pm     Reply with quote

Yes, the driver sends out a carriage return of 13, 10, which is standard. I have no control or access to how the driver sends things, but I do know for a fact that it sends out a standard CR.

I guess my PIC is the Master PIC you are referring to in which case I'm using puts instead of printf, which already has the CR behind it. But the driver is receiving the data I send out no problem, it's my PIC receiving the data the driver is sending out that is giving me issues.
_________________
KMoe

~We the willing, led by the unknowing, are doing the impossible for the ungrateful. We have done so much, for so long, with so little. We are now qualified to do anything with nothing -M. Theresa
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 21, 2008 7:03 pm     Reply with quote

Don't put any delays before you call get_string(). In your original code,
you have a 500 us delay after you send the command to start sending
the data. That delay can cause you to miss incoming characters if
more than 3 of them come in during that time.
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