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

picKit 2 UART tool dsPIC33

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



Joined: 01 Apr 2010
Posts: 5

View user's profile Send private message

picKit 2 UART tool dsPIC33
PostPosted: Thu Apr 01, 2010 3:45 pm     Reply with quote

I am starting up a project with dsPICFJ128GP802 and I've made all the basic connections. I'm using PIC Kit 2 to power it up and the first thing I wanted to do is to use PICKit 2 UART tool to send a character to the UART screen. Here's my code:
Code:

#include <33fj128gp802.h>
#fuses HS, NOWDT, PR_PLL, NOPUT
#use delay (clock=20000000)
#use rs232(baud=9600, XMIT=PIN_B0, RCV=PIN_B1, ERRORS)

void main()
{
   while(1)
   {
      putc('n');
      output_toggle(PIN_B4);
      delay_ms(2000);
   }
}

I have an LED connected to pin B4 and its doing the toggle correctly.
Here is what I'm getting in the UART Tool screen
Quote:
?????????
RX: FD
RX: FD
RX: FD
RX: FD


The ? is when I select the ASCII mode and RX: FD is in Hex mode. Does anyone have an idea on why I am getting the '?' instead of 'n' ? It's the same no matter what character or number I put. Thanks in advance.
My compiler version is PCD 4.084, 57706.
sniffer



Joined: 01 Apr 2010
Posts: 5

View user's profile Send private message

picKit 2 UART tool dsPIC33 (SOLVED)
PostPosted: Mon Apr 05, 2010 6:24 pm     Reply with quote

I had the fuse setting wrong. I should have used PR instead of PR_PLL. Changed it and now its working.
sniffer



Joined: 01 Apr 2010
Posts: 5

View user's profile Send private message

PostPosted: Mon Apr 05, 2010 9:12 pm     Reply with quote

I'm having another simple problem and I also connected MAX233 and used a serial cable instead of using PIC Kit's UART tool because I didnt trust the tool very much, but I am still having the problem.
Code:

#include <33fj128gp802.h>
#fuses HS, NOWDT, PR, NOPUT
#use delay (clock=20M)
#use rs232(baud=9600, XMIT=PIN_B7, RCV=PIN_B6, ERRORS)

void main()
{
   while(TRUE)
   {
       printf("Hello");
      delay_ms(2000);     
   }
}

On the Serial Port Monitor, what's happening is that "Hello" is being displayed only once when the program initially runs and then the program does nothing. However, if I print "Hel" or any other 3 characters then the program works fine as intended. As soon as I try to print 4 or more characters it doesn't work. I had this problem with PICKit's UART tool as well which is why I switched to a regular serial port instead. Any clues on what may be causing this odd behavior?

The PIC runs at 3.3v and MAX233 is powered up with 5V, I've connected output of MAX233 to PIC's 5V tolerable pins B6 and B7.
sniffer



Joined: 01 Apr 2010
Posts: 5

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 8:23 pm     Reply with quote

I tried to see if I could find anything from the .lst file. I noticed that the generated code are similar when I have printf("Hel") or printf("He"). But when I have printf("Hell") or more than 4 characters, then the .lst file is different.
I have pasted parts of the .lst file below for all 3 cases, could anyone please recompile my code using a different PCD compiler and see if you get the same kind of code for the 3 cases?
For printf("He):
Code:

....................    while(TRUE)
....................    {
....................       printf("He");
00244:  MOV.B   #48,W0L
00246:  MOV.B   W0L,801
00248:  CALL    200
0024C:  MOV.B   #65,W0L
0024E:  MOV.B   W0L,801
00250:  CALL    200
....................       delay_ms(2000);       
00254:  MOV     #7D0,W0
00256:  CALL    224
....................    }
0025A:  GOTO    244
.................... }


For printf("Hel"):
Code:

....................    while(TRUE)
....................    {
....................       printf("Hel");
00244:  MOV.B   #48,W0L
00246:  MOV.B   W0L,801
00248:  CALL    200
0024C:  MOV.B   #65,W0L
0024E:  MOV.B   W0L,801
00250:  CALL    200
00254:  MOV.B   #6C,W0L
00256:  MOV.B   W0L,801
00258:  CALL    200
....................       delay_ms(2000);       
0025C:  MOV     #7D0,W0
0025E:  CALL    224
....................    }
00262:  GOTO    244
.................... }


For printf("Hell"):
Code:

....................    while(TRUE)
....................    {
....................       printf("Hell");
00256:  MOV     #0,W1
00258:  MOV     W1,W0
0025A:  CALL    200
0025E:  INC     W1,W1
00260:  MOV.B   W0L,801
00262:  CALL    212
00266:  MOV     #3,W0
00268:  CPSGT   W1,W0
0026A:  BRA     258
....................       delay_ms(2000);       
0026C:  MOV     #7D0,W0
0026E:  CALL    236
....................    }
00272:  GOTO    256

Please let me know if you need more parts of the code. Thanks.
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Thu Apr 08, 2010 9:29 pm     Reply with quote

My speculation: It looks like for 3 of less characters the compiler stores the characters 'inline'. #48, #65, and #6C correspond to 'H', 'e', and 'l'. For more than 3 characters, the code becomes more compact if the compiler creates a loop and accesses successive characters stored elsewhere.

Rohit
gpsmikey



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

View user's profile Send private message

PostPosted: Wed Dec 22, 2010 2:12 pm     Reply with quote

Quote:
I'm using PIC Kit 2 to power it up and the first thing I wanted to do is to use PICKit 2 UART tool


Not sure if this applies here, but in a somewhat older readme for the PICkit2, on using the UART Tool I just came across, I found the following comment:

Quote:
IMPORTANT CONNECTION NOTES:
PICkit2 cannot supply Vdd when using the UART Tool. The PICkit 2 Vdd pin MUST be connected to the target UART Vdd or it will NOT work


I just happened across this in doing some research on the UART tool also
http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit%202%20Readme%20v2-40.txt
Very Happy

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