![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
McNerd Guest
|
Having no luck with pic to pic rs232 |
Posted: Tue Oct 28, 2008 10:32 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
McNerd Guest
|
having no luck with pic to pic rs232 |
Posted: Tue Oct 28, 2008 11:08 pm |
|
|
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... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 28, 2008 11:19 pm |
|
|
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:
You should be doing this:
Then the TRIS will be handled automatically. |
|
![](templates/subSilver/images/spacer.gif) |
McNerd Guest
|
God i'm an idiot |
Posted: Tue Oct 28, 2008 11:30 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|