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

Problems with #use rs232

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



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

Problems with #use rs232
PostPosted: Fri May 07, 2004 11:07 am     Reply with quote

I have a 16F819 with a HS:8Mhz clock. Its connected to a max 233 level converter which has been tested and is working properly. I can putc('u') but when I putc(getc()) nothing comes out the transmit line. I have an oscilliscope connnected to transmit and recieve. I see the out put from my computer using hyper terminal but nothing comes out the pic. Is there a timeframe issue? Is there a register i can look at to see the incoming data? Any6 help would be much appreciated.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri May 07, 2004 12:07 pm     Reply with quote

Hi BMaxwell,

Itīs not possible to help you while we doesnīt have enough info, at least we need:
1) your code with headers and directives
2) cross-compiler version
3) the most relevant comments regarding the hardware.

rgds,

Humberto
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 07, 2004 12:32 pm     Reply with quote

Can you write a simple program to spew ASCII characters 0 through 255 repeatedly and look at the output with the scope? I recommend adding a sync pulse out of another pin at the start of each character to sync your scope to.
That should test out the putc() and hardware functions.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Fri May 07, 2004 1:06 pm     Reply with quote

The compiler is 3.148. The code looks like this
#include <16F819.H>

#use delay(clock=8000000)
#use fast_io(a)
#use rs232(baud=19200, xmit=PIN_A1, rcv=PIN_A0)
#use I2C(master, sda=PIN_B4, scl=PIN_B5, fast)


void main()
{
setup_adc_ports( ALL_ANALOG );
while(TRUE)
putc( getc() );


}

I am using a 16F819 Pic micro controller with a max 233a level converter. I am alos using a 24C256 for another program, this is just to get the Rs232 to work. In both programs it stops at the first getc.
Thanks for all the help.
Bryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 07, 2004 1:32 pm     Reply with quote

Quote:
In both programs it stops at the first getc.

Look at the parts of your program that I have highlighted
in red, below:

#use delay(clock=8000000)
#use fast_io(a)
#use rs232(baud=19200, xmit=PIN_A1, rcv=PIN_A0)
#use I2C(master, sda=PIN_B4, scl=PIN_B5, fast)

void main()
{
setup_adc_ports( ALL_ANALOG );
while(TRUE)
putc( getc() );

}
BMaxwell



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

Doh
PostPosted: Fri May 07, 2004 1:51 pm     Reply with quote

Ya I changed that line to no analogs but I still recieve no response. Is there any way to check a register? Im open to any suggestions. Thanks in advance.
Bryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 07, 2004 2:03 pm     Reply with quote

Well, the reason is this line:

#use fast_io(a)

But you are not setting the TRIS for the transmit pin
(Pin A1) to be an output. It comes up as an input
pin upon power-up.

I normally avoid using fast_io. Unless you need the
ROM space or the speed, it's better to let the compiler
automatically handle it. If you did not use the fast_io()
line, then your program would already be running.
BMaxwell



Joined: 07 May 2004
Posts: 20

View user's profile Send private message

That worked thanks
PostPosted: Fri May 07, 2004 4:08 pm     Reply with quote

Sweet that worked thanks pcm guy Smile. One last question if I want a pin to go low, should I use output_bit(0, PIN_A2), or output_low(PIN_A2) when using standard io?
Thanks again pcm.
Bryan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 07, 2004 4:13 pm     Reply with quote

Quote:
should I use output_bit(0, PIN_A2), or output_low(PIN_A2)
when using standard io?

Use this:

output_low(PIN_A2);
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