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

Having no luck with pic to pic rs232

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







Having no luck with pic to pic rs232
PostPosted: Tue Oct 28, 2008 10:32 pm     Reply with quote

I've searched using several queries and read the first five pages of each search, and I'm still not having luck with pic to pic rs232. Here's my source:
Code:
#include <12F508.h>
#USE DELAY (clock=4mhz)
#USE STANDARD_IO (ALL)
#USE rs232(BAUD=9600,XMIT=PIN_B4,RCV=PIN_B5,PARITY=N,BITS=8)
#FUSES INTRC, NOWDT, NOMCLR, NOPROTECT

#DEFINE PORTB 6
void write()
{
  char d=0,len;

  for(;;d++)
  {
    putc(d);
    if (d==7) d=0;
    delay_ms(500);
  }
}

void read()
{
  char d=0;

  for(;;)
  {
    while(!kbhit());
   
    d=getc();   
 
    *PORTB=d;
  } 
}

void main()
{
  #asm
  movlw 223
  option
  #endasm
 
  write();
  //read();

}


The asm lets me use pin b2, but you already knew that... as an aside, any "c" way to do that ? Anyway, I have b4 connected to b5 and vice versa. I've tried pulling the lines high and/or low, as well as not pulled at all. perhaps i'm using too high/low values of resistors. For one, it seems as if the tris values are not being set automatically as they should. I had set trisb to 0, and I had activity on b4 as appropriate, however, as soon as i eliminated that line I am seeing no activity of any kind. That will be the last thing I try before I hit the sack tonight. Tris of b4 goes to 0 and b4 needs a 1, correct ? I am certain this is an obnoxiously simple problem, and I was leaning toward it being a hardware/hookup problem until this tris thing reared it's head. Anyways, thanks in advance for any help
McNerd
Guest







having no luck with pic to pic rs232
PostPosted: Tue Oct 28, 2008 11:08 pm     Reply with quote

set up tris manually and it works fine. I feel soooooooo retarded. i tried this on a whim a while ago and i must not have powered the chip down and back up...

i thought using #USE STANDARD_IO (ALL) made it so i could ignore tris ?

odd...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 11:19 pm     Reply with quote

Quote:
I thought using #USE STANDARD_IO (ALL) made it so i could ignore tris ?

That only works if you use the CCS i/o functions.

You're writing directly to Port B:
Quote:
*PORTB=d;


You should be doing this:
Code:
output_b(d);

Then the TRIS will be handled automatically.
McNerd
Guest







God i'm an idiot
PostPosted: Tue Oct 28, 2008 11:30 pm     Reply with quote

You see........ i've never done it that way before. "that way" being standard_io/output_x() always use fast_io........

oh well, i set the tris and dumped standard_io. my usual. and it works like a charm. pretty cool stuff man.
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