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

[help] "fprintf" can not display normally

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







[help] "fprintf" can not display normally
PostPosted: Thu Oct 19, 2006 11:36 am     Reply with quote

now I have a GPS receiver called GPS 35LVS and I want to use it on the platform of 16F877A. The compiling environment is CCS and ICD u40. Now I want to receive the data from the GPS and echo them to Debugger monitor via ICD U40, and there are some problem with the fprintf built-in function. Because I will use RS232 for GPS and RS232 for Debugger, I have to use fprintf fucntion to display the data on the monitor, however it can not display normally, just like something about Chinese characters. And, when I just use RS232 for debugger, the printf fucntion can perform normally. I do not know why.. A lot of thanks in advance for your kind ...
by the way, my notebook Operating System is Windows XP Chinese Edition
here is the code.

Code:
#include<16f877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#device ICD=TRUE
#use delay(clock=8000000)
#use RS232(baud=4800, parity=N, xmit=PIN_C6, rcv=PIN_C7, stream=GPS)
#use RS232(baud=9600, xmit=pin_B3, rcv=pin_B3, stream=DEBUG)
      VOID main ()
      {
         INT i;
         CHAR GPS_packet[70];
         CHAR c;

      DO
      {
         i = 0;
         FOR (i = 0; i <= 70; i++)
         {
            c = fgetc(GPS);
            GPS_packet[i] = c;
         }

         FOR (i = 17; i <= 40; i++)
         {
            fprintf(DEBUG,"%C",GPS_packet[i]);// here is where the problem exsit.
         }
      }WHILE(kbhit());

      }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 19, 2006 12:58 pm     Reply with quote

The CCS manual doesn't say the keyword is 'DEBUG'.
It says it is 'DEBUGGER'.
Guest








PostPosted: Thu Oct 19, 2006 4:02 pm     Reply with quote

I find it in the CCS help document, in the Built-in Function->RS232 I/O->GETC, and there is an example on the bottom.
Code:

printf("Continue (Y,N)?");

do {

   answer=getch();

}while(answer!='Y' && answer!='N');

 

 

#use rs232(baud=9600,xmit=pin_c6,

           rcv=pin_c7,stream=HOSTPC)

#use rs232(baud=1200,xmit=pin_b1,

            rcv=pin_b0,stream=GPS)

#use rs232(baud=9600,xmit=pin_b3,

            stream=DEBUG)

...

while(TRUE) {

   c=fgetc(GPS);

   fputc(c,HOSTPC);

   if(c==13)

     fprintf(DEBUG,"Got a CR\r\n");

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 19, 2006 4:27 pm     Reply with quote

I don't have the CCS ICD-U40, so I can't test it for you.
All I can do is to read the manual. The last manual for vs. 3.249
of the compiler, says to do it this way:
Quote:

Debugger - Monitor
The monitor window shows data from the target and allows entry
of data to be sent to the target. This is done on the target like this:

#use RS232(DEBUGGER)

... printf(�Test to run? �);
test=getc();

For the PIC16 ICD the B3 pin is used on the target to implement this
capability. The normal ICD cable is already set up correctly for this.



The current manual for vs. 4.xxx also says to use the keyword DEBUGGER.
Code:

DEBUGGER   Indicates this stream is used to send/receive data
           though a CCS ICD unit. The default pin used in
           B3, use XMIT= and RCV= to change the pin used.
           Both should be the same pin.

My suggestion is, if you are having problems, then follow the manual
exactly.

I can't help you any more on this topic. Someone else who has the
ICD-U40 will have to help.
forwardti
Guest







PostPosted: Fri Oct 20, 2006 1:57 am     Reply with quote

okey! Thank you a lot.
I wil try that.
Actually, I thought only when I use "#use RS232(baud=9600, xmit=PIN_B3, rcv=PIN_B3, stream=DEBUG)", could I use the stream DEBUG for the monitor under the condition of two RS232.
so, I'll try that, Thank you!
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