View previous topic :: View next topic |
Author |
Message |
BMaxwell
Joined: 07 May 2004 Posts: 20
|
Problems with #use rs232 |
Posted: Fri May 07, 2004 11:07 am |
|
|
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
|
|
Posted: Fri May 07, 2004 12:07 pm |
|
|
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
|
|
Posted: Fri May 07, 2004 12:32 pm |
|
|
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
|
|
Posted: Fri May 07, 2004 1:06 pm |
|
|
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
|
|
Posted: Fri May 07, 2004 1:32 pm |
|
|
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
|
Doh |
Posted: Fri May 07, 2004 1:51 pm |
|
|
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
|
|
Posted: Fri May 07, 2004 2:03 pm |
|
|
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
|
That worked thanks |
Posted: Fri May 07, 2004 4:08 pm |
|
|
Sweet that worked thanks pcm guy . 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
|
|
Posted: Fri May 07, 2004 4:13 pm |
|
|
Quote: | should I use output_bit(0, PIN_A2), or output_low(PIN_A2)
when using standard io? |
Use this:
output_low(PIN_A2); |
|
|
|