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 support@ccsinfo.com

comm port setup problem

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



Joined: 09 Mar 2007
Posts: 31

View user's profile Send private message

comm port setup problem
PostPosted: Thu Jan 10, 2008 10:30 pm     Reply with quote

Hi,
I have 2 comm ports which one of it I want to use for communicate with PIC. So, how to set up this port?
thanks
arys



Joined: 09 Mar 2007
Posts: 31

View user's profile Send private message

PostPosted: Fri Jan 11, 2008 2:26 am     Reply with quote

I've tried max232 IO with hyperterminal and it is work.
but when i connect max232 IO to PIC16f873. It doesnt work.
Nobody knows? Plsss..here my simple code (the simplest .. Laughing )
Code:
  #define (_PCH_)
#include <16f873.h>
#use delay (clock=4000000)
#fuses XT,NOWDT,NOPROTECT
#use rs232(baud=9600,xmit=pin_c6, rcv=pin_c7, bits=8)

void main()
{
while (true)
{
   if (getc()=='1')
      output_high (PIN_B7);
}

}
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Fri Jan 11, 2008 12:53 pm     Reply with quote

See PCM Programmer's src code here : http://www.ccsinfo.com/forum/viewtopic.php?t=32831&highlight=getc
At first, try if the PIC responds.
In the case of using PLL, make sure your delay command is set properly.
What is the crystal you use?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 11, 2008 1:32 pm     Reply with quote

Add the NOLVP fuse. Without it, the PIC will lockup if the PGM pin
(pin B3 on the 16F873) goes high. Do this in all your programs.
Quote:
#fuses XT,NOWDT,NOPROTECT,NOLVP


Also add the ERRORS parameter as shown below. Without it, the
hardware UART's receiver can lock-up if it receives more than two
characters and you don't read at least one of them with getc().
Do this in all your programs.
Quote:

#use rs232(baud=9600,xmit=pin_c6, rcv=pin_c7, bits=8, ERRORS)
arys



Joined: 09 Mar 2007
Posts: 31

View user's profile Send private message

PostPosted: Sun Jan 13, 2008 6:08 pm     Reply with quote

hi guys..it's works. thanks to all.
arys



Joined: 09 Mar 2007
Posts: 31

View user's profile Send private message

PostPosted: Mon Jan 14, 2008 2:11 am     Reply with quote

Hi..it comeout with new problem. I changed the code to lightup the LED through Visual basic, it doesnt work. But when I use hyperterminal, it works. What's wrong with VB? Hope someone help me. Here I attach the code
Code:
 #define (_PCH_)
#include <16f873.h>
#use delay (clock=4000000)
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use rs232(baud=2400,xmit=pin_c6, rcv=pin_c7, bits=8, ERRORS)

void main(void)
{
char c;

while(1)
  {
   c = getc();
   if (c=='1'){
   output_high(PIN_B5);
    delay_us(400);
    output_low(PIN_B5);
    delay_us(1600);
   putc(c); }
  }
}
mir_as82



Joined: 05 Nov 2007
Posts: 3

View user's profile Send private message

can you give your vb codes??
PostPosted: Mon Jan 14, 2008 3:36 am     Reply with quote

firstly check your baudrate,databits,flow control...and other quantities about serial connection.
PIC side and VB side must have same settings about serialport.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jan 14, 2008 8:40 am     Reply with quote

Two small remarks.

Code:
 #define (_PCH_)
Why do you define this value? This looks like a compiler internal setting and shouldn't be there. Besides, the PIC16F873 is to be compiled with PCM, not PCH.

Code:
delay_us(400);
This is a very short time for blinking a LED. You can actually see this 0.0004 second pulse??? Or did you mean to use delay_ms() instead?
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