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

How to direct fprintf() output to MPLAB Output Window?

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



Joined: 06 Mar 2009
Posts: 10
Location: Salinas, CA

View user's profile Send private message

How to direct fprintf() output to MPLAB Output Window?
PostPosted: Sun May 19, 2013 10:50 am     Reply with quote

Hi Everyone,

I was wondering if it is possible to direct the printf() or fprintf() output to the MPLAB Output WIndow. I found the topic dealing with this using MPLAB Sim. This worked fine. However, I would like to try this using data sent from the PIC MCU via the PICKit3 programmer. Here is my setup:

CCS ver. PCH 3.249
MPLAB IDE ver. 8.89
Programmer: PICKit 3

...and here is my code
Code:

#include <18F2420.h>
#include <stdlib.h> 

#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT
#use delay(clock=4915000)

#use rs232(baud=9600, xmit=PIN_C6, bits=8, rcv=PIN_C7, parity=N, bits=8) 
                                                           
void main() {

   //fprintf(stderr,"Hello World\n");    // this works with MPLAB Sim
   printf("Hello World\n");              //...so does this
   
   while(1) ;
   
}


Thanks in advance for your help. By the way, in case anyone is wondering, I don't happen to have a RS-232 cable at the moment so I am trying this as a temporary solution.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun May 19, 2013 7:48 pm     Reply with quote

I don't have a pickit 3, however, the pickit2 (which is what I have) has a "uart tool" mode - the 3 may have the same thing (or you may have a 2 also around). I have used that in debugging many times and it works fairly well. That allows you to have a connection to the PC from your board via the pickit - you just declare a stream then use fprintf to talk to it - here are a couple of key lines from my little test program I was using to simulate a fuel gauge sender:

Code:
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B6, ERRORS, PARITY=N, \
            BITS=8, STREAM=MIKEYMON)
////////////////////////////////////////////////////////////////////
//
// Gas Tank Sender simulator using PWM - M. Fields  12-July-2011
// uses the Microchip PICKit 2 18 pin demo board with a 16F1827 processor
// installed. ( DM164120-4 )
//
////////////////////////////////////////////////////////////////////

/

void disp_pct(int duty, int cycle)   // display duty cycle percentage
   {
   pct = ((int16) duty * 100) / cycle ;
   fprintf(MIKEYMON,"Duty Cycle = %u%% (%u/%u)\r\n",pct, duty, width);


Hopefully that will help :-)
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
jcal54321



Joined: 06 Mar 2009
Posts: 10
Location: Salinas, CA

View user's profile Send private message

PostPosted: Tue May 21, 2013 10:44 pm     Reply with quote

Hi GPSMikey,

Thanks for your reply. I tried as you have suggested, but it did not work. Also the PICKit3 documentation has no mention of the UART Tool that you have with the PICKit2. It is too bad. I think it would have been a nice feature to have been maintained in the PICKit3. It certainly would have been helpful troubleshooting any serial port issues.

Thanks again for your reply. Best regards.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue May 21, 2013 11:24 pm     Reply with quote

Too bad they didn't put that feature in the Pickit3 - quite a while back, I had looked into getting the 3, but it was still early in development. Unfortunately, it seems to have been frozen in the "early in development" stage. The uart tool was a handy feature for debugging.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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