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

rs232 software
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Mon Nov 05, 2012 5:17 pm     Reply with quote

I would like to connect a pic microcontroller via rs232 to pc.

I need to ask if i need any other software (for the pc ) . (i don't mean the pic programming)
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Mon Nov 05, 2012 5:44 pm     Reply with quote

If you simply need a terminal program for debugging, then the "SIOW" program bundled with the CCS compiler works well. If you don't have the windows version of the compiler (SIOW is bundled with it, I believe), then "realterm" (google it) is very good.
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Fri Nov 30, 2012 12:28 pm     Reply with quote

I used "realterm"with a MAX232IN component and the following code but something is wrong. I can not see any character to my screen.

The code which I used is:
Code:

#include <33fj128mc802.h>

#fuses HS                   
#fuses NOWDT           
#fuses NOPROTECT     
#use delay (clock=20000000) 
#use rs232(baud=9600, xmit=PIN_B14,rcv=PIN_B15)

void main(void) {

int i;
char buffer[10]={'0','1','2','3','4','5','6','7','8','9'};

putc('*');

output_low(PIN_A0);
output_low(PIN_A1);
while(1)

   output_high(PIN_A0);
   output_high(PIN_A1);
   for(i=0;i<=10;i++) {
      putc(buffer[i]);
     
   }
   putc(13);
delay_ms(100);
output_low(PIN_B0);
output_low(PIN_B1);
}
}


First of all my code is ok??
How can I use the realterm ?? (There are any setting which i have to change?)
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 30, 2012 12:51 pm     Reply with quote

I don't use the 33 series PICs but..some have programmable pin uses and there's a CCS C 'command' to tell the compiler which pin is used for what fuction. Others using that PIC will know

As for your program, I'd start with the simple example CCS gives of 'getting a character form PC and sending it back' AKA active loopback test.By keeping things simple, you'll get it working faster.

Also the simple '1Hz LED' program is a great start as well.it PROVES the PIC and your code is OK.

hth
jay
gpsmikey



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

View user's profile Send private message

PostPosted: Fri Nov 30, 2012 1:08 pm     Reply with quote

Definitely second the "blinkey led" thing - not only tells you the PIC is alive, but lets you verify the clock is being set correctly (if the clock is wrong, the RS232 ain't gonna talk to the PC) - if you are setting the LED to blink at a 1hz rate and it isn't, the baud rate will be wrong also. I also like to use a spare pin if I have it to set it high going into an ISR then set it low just before exiting - lets me look at the pulse width on a scope and see just how much time the ISR is actually spending in the ISR.

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
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Wed Dec 05, 2012 3:05 am     Reply with quote

I used max232 with putty and the code bellow.My problem is that, nothing appear at my screen. Is anyone who know what is going wrong?????


#include <33fj128mc802.h>


#fuses HS
#fuses NOWDT
#fuses NOPROTECT
#use delay (clock=20000000)
#use rs232(baud=9600, xmit=PIN_B8,rcv=PIN_B9)


void main(void) {

int i;
char buffer[10]={'0','1','2','3','4','5','6','7','8','9'};

putc('*');

output_low(PIN_A0);
output_low(PIN_A1);
while(1)
{
for(i=0;i<=10;i++) {
putc(buffer[i]);


}
putc(13);
output_high(PIN_A0);
output_high(PIN_A1);

delay_ms(100000000);
output_low(PIN_A0);
output_low(PIN_A1);
}
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 4:02 am     Reply with quote

First, have you followed Temtronic's suggestion about the 1Hz LED test.

At the moment you are like the person saying "I can't get my car to move", who is not responding to the question 'can you start the engine'.....

Then look at the first line of Temtronic's post. 'programmable pin uses'. Your PIC _does_ have relocatable pins, and these need to be setup. The syntax is:

Code:

#PIN_SELECT U1TX=PIN_B14
#PIN_SELECT U1RX=PIN_B15
#USE RS232(UART1,ERRORS,BAUD=9600)
//In place of your current RS232 line


However get the LED test going first. Nothing will work, till the chip _is_ running at the right speed.

Best Wishes
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Wed Dec 05, 2012 6:55 am     Reply with quote

Thanks guys for your answer but please can you make clear what do you mean by 1Hz LED test ????
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 7:07 am     Reply with quote

Hi andys,

Please forgive my shock, but after 83 posts and 6 years on the forum,
you still seem surprisingly helpless Shocked .......

Connect an LED from one PIC I/O pin to GND thru a suitable current
limiting resistor, and load some code onto the PIC to flash the LED at a
predictable rate. This test will tell you two things: (1) your PIC is actually
executing code, and (2) the execution speed of the PIC is correct.

Code:

While(1) {

output_high(LED);
delay_ms(500);
output_low(LED);
delay_ms(500);

}


This simple test should be the FIRST thing that you do every time you
start a new PIC project!

Good Luck!

John
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 7:55 am     Reply with quote

Did you really mean to include this in your code?
Code:
delay_ms(100000000);

What did you think might happen?

Have you tested your PC's RS232?

Connecting the TX to the RX should cause any characters typed on your PC to appear on the screen. (Once per keystroke without echo, twice with.)

Like ezflyr says we should not be having this conversation.

Mike
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Wed Dec 05, 2012 5:44 pm     Reply with quote

Dear ezflyr,

I know the following procedure

"Connect an LED from one PIC I/O pin to GND through a suitable current
limiting resistor, and load some code onto the PIC to flash the LED at a
predictable rate. This test will tell you two things: (1) your PIC is actually
executing code, and (2) the execution speed of the PIC is correct. "

With this procedure you can test if the PIC is actually
executing code but you need an oscillator to measure the execution speed of the PIC (correct me if i am wrong).

Furthermore i used the code bellow is anyone who can help me/suggest me what to do???
Code:

#include <33fj128mc802.h>

#fuses HS
#fuses NOWDT
#fuses NOPROTECT
#use delay (clock=20000000)

#PIN_SELECT U1TX=PIN_B14
#PIN_SELECT U1RX=PIN_B15
#USE RS232(UART1,ERRORS,BAUD=9600)


void main()
{
putc('*');

while(1)
  {
   puts("A");
   puts("\n");
   output_high(pin_A0);
   delay_ms(500);
   output_low(pin_A0);
   delay_ms(500);
   putc(13);
  }

}
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 7:39 pm     Reply with quote

With respect to the 1Hz test program, no test equipment is really necessary except for your eyeballs.
If the LED flashes at all, your PIC should be alive and well...
If it flashes about 1Hz, that's like 'one steamboat,two steamboat' in timing and that's good too.
This simple program will confirm that
1) the hardware you've constructed is good(layout,pinout,etc.)
2) the code you cut is good
3) the selection of 'fuses' is appropriate
4) that serial communications(aka RS232) should work as well.
5) that you've programmed the PIC in RELEASE mode and NOT DEBUG.

With respect to your code.
I don't use the 33 series however..general trouble shooting comments..

Are you using a real RS232 comport on your PC or a USB<>RS232 module.
Do you have a MAX232 or equal between your PIC and the PC?
Do you have PIC TX to PC RCV ?
Do you have a good ground between the two devices?
Is the PIC running on 3 or 5 volts?
Do you get anything on the PC at all?
Can you confirm, via a loopback(pin 2---pin3) that the PC software is running?

Note: if using a USB port, please note that a TTL<->USB adapter is NOT the same as an RS232<->USB adapter.

I know some points are obvious...but the more information you can supply, the better we can help.

hth
jay
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

rs232 software
PostPosted: Wed Dec 05, 2012 7:52 pm     Reply with quote

Are you using a real RS232 comport on your PC or a USB<>RS232 module.
--> I used a real RS232

Do you have a MAX232 or equal between your PIC and the PC?
--> YES A MAX 232

Do you have PIC TX to PC RCV ?
--> Yes i used female port which include tx,rx,gnd

Do you have a good ground between the two devices?
-->Yes i used the ground which is provided by the microkit 2 which i used

Is the PIC running on 3 or 5 volts?
--> power supply 3.3V (provided by the microkit 2)

Do you get anything on the PC at all?
-->nothing

Can you confirm, via a loopback(pin 2---pin3) that the PC software is running?
-->how to do this?
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 8:05 pm     Reply with quote

re loopback test.
Disconnect any wiring to the PIC setup...
Connect a wire between pin 2 of the PC comport DE-9 connector and pin 3.
This sends anything you type on the PC keyboard out pin 3(xmt) and then into the PC via pin 2(rcv) which will show up on the PC screen.

Just be sure whatever serial communications software you're using an NO flow control set! If this test fails..then either the software you're using is faulty,not setup correctly or a hardware issue.

I use Realterm and Hyperterminal for 'quick' testing.

hth
jay
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

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

PostPosted: Wed Dec 05, 2012 9:34 pm     Reply with quote

Just a note that if your power supply is 3.3V, then you should be using a MAX3232 (good for 3.3V) and not a MAX232 (good for 5V).
_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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