View previous topic :: View next topic |
Author |
Message |
Sophi
Joined: 14 Jun 2005 Posts: 64
|
RS232 HELP- using Hyperterminal |
Posted: Wed Jun 29, 2005 11:12 am |
|
|
Here's my code (below) for a simple communication with Hyperterminal. I don't see anything (scope) on the receive line (C7) but do see action on C6 when I remove the lines:
C = getch();
putc('y');
Can someone help me with a communication example? - I am totally new to this so perhaps I have hyperterminal configured wrong as well?
Thanks-
Sophi
My settings:
connected Direct to Com 2
bits per second- 9600
data bits- 8
parity- none
flow control- none (I find I can't type to the screen without this setting)
IN ADVANCED- I unchecked FIFO buffer
IN ASCII setup- checked echo typed characters locally and wrap lines
My code:
#include <16c74a.H>
#device ICD=TRUE
#fuses HS,NOPROTECT,NOWDT,NOBROWNOUT,PUT
#use delay(clock=20000000) // adjust for resonator frequency
#include <LCD2_877A.c>
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdio.h>
main()
{
init:
lcd_init();
lcd_putc("\fWELCOME\n"); // welcome
delay_ms (1000); // wait for amps & a/d to stabilize
output_low (PIN_A0); // turn LED off
delay_ms(2000);
setup_adc_ports(NO_ANALOGS); // sets port A all digital
setup_adc( ADC_OFF ); // no analog
output_high (PIN_A0); // LED on
delay_ms (250);
while(1) // while true
{
int C;
putc('h');
output_high (PIN_A0); // LED on
C = getch();
putc('y');
delay_ms (1);
output_low (PIN_A0); // LED off
delay_ms (1);
}
} //end main |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Jun 29, 2005 11:42 am |
|
|
Quote: |
I am totally new to this so perhaps I have hyperterminal configured wrong as well?
|
http://www.ccsinfo.com/forum/viewtopic.php?t=9253&highlight=hiperterminal
Quote: |
My settings:
connected Direct to Com 2
|
RS232 handle a different voltage than the +5V you are using with the PIC and logic.
You�ll need a level translator (MAX232 or similar) to connect your PIC with the PC.
I guess you are very new with this and in order to narrow your needs, I strongly
suggest to search "RS232" in this forum and you will find a lot of good info
to read and learn from and surelly to solve your problem.
Best wishes,
Humberto |
|
|
Sophi
Joined: 14 Jun 2005 Posts: 64
|
reply |
Posted: Wed Jun 29, 2005 12:03 pm |
|
|
Thanks Humberto-
Yes I read everything in the forum - that's how I chose all my settings for Hyperterminal!
I am using a Protoboard (Olimex) that comes with a MAX232 chip. I've connected TX from the MAX232 to PIC- C6 and RX from MAX232 to PIC C7. I'm using a PIC16C74A.
Any advice is appreciated!
Sophi |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Jun 29, 2005 12:26 pm |
|
|
Quote: |
Yes I read everything in the forum
|
Well done !
Lets start with this simple code just to be sure that your hardware is Ok.
Code: |
#include <16c74a.H>
#device ICD=TRUE
#fuses HS,NOPROTECT,NOWDT,NOBROWNOUT,PUT
#use delay(clock=20000000) // adjust for resonator frequency
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
main()
{
setup_adc_ports(NO_ANALOGS); // sets port A all digital
output_low (PIN_A0); // turn LED off
delay_ms(300);
output_high (PIN_A0); // LED on
printf("\r\nMy mssge to PC");
output_low (PIN_A0); // turn LED off
while(1); // stop here
}
|
|
|
|
Sophi
Joined: 14 Jun 2005 Posts: 64
|
|
Posted: Thu Jun 30, 2005 8:21 am |
|
|
Humberto-
thanks ! for the code- I copied it exactly and started HTerm.
Nothing happens. Is there a setting I need to receive data from the PIC?
BTW LED works so code is working.
Thanks-
Sophi |
|
|
Jose Guest
|
|
Posted: Thu Jun 30, 2005 8:34 am |
|
|
#include<16f877a.h> //Change it to your Chip ##
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
void main(){
setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports(ALL_ANALOG);
set_adc_channel(1);
while (TRUE){
printf("Look Behind You");
}
}
above is a small code to test the Hyper terminal make sure u have a serial port connected to your RS232
set your Hyper terminal to the following
9600
8
none
1
none
and it should keep writing that line forever |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
Re: RS232 HELP- using Hyperterminal |
Posted: Thu Jun 30, 2005 8:38 am |
|
|
Sophi wrote: | My settings:
connected Direct to Com 2
bits per second- 9600
data bits- 8
parity- none
flow control- none (I find I can't type to the screen without this setting)
IN ADVANCED- I unchecked FIFO buffer
IN ASCII setup- checked echo typed characters locally and wrap lines
|
1) Re-check the FIFO buffer.
2) Are you 100% certian that the serial port to which you have connected your cable is COM2?
3) Did you build the circuit or buy something pre-made.
4) Do you have the right kind of RS232 cable. Do you need a NULL cable or a STRAIGHT cable?
5) If you built the circuit, have you checked that your MAX232 chip has the appropriate voltages on its charge pump pins? Its VCC pin? Have you looked at the TX signal from the PIC with an oscilloscope to see if it is moving? Have you looked at the TX signal after the MAX232 with an oscilloscope to see if it is moving? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Thu Jun 30, 2005 10:31 am |
|
|
And of course, take the extremely obvious step of making sure that hyperterminal is set correctly-- whichever Com port you're plugged into, 8 data bits, 1 stop bit, no parity, no flow control, and 9600 baud.
Scott |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Jun 30, 2005 10:32 am |
|
|
After you checked all the steps suggested by rwyoung I would like
you check the following wiring:
Code: |
PIC MAX232
PIN_C6 >-------- Should be PIN 10 or 11
PIN_C7 <-------- Should be PIN 12 or 9
|
And the voltages in MAX232 while running the posted code:
MAX232:
PIN2 (.... V) Read and post the voltage (+)
PIN6 (.... V) Read and post the voltage ( -)
PIC:
PIN_C6: Must be High
PIN_C7: Must be High
Hope you have read all the gotchas in the link I posted regarding Hiperterminal use.
I strongly recommend to try another Comm monitor.
Keep well,
Humberto |
|
|
Sophi
Joined: 14 Jun 2005 Posts: 64
|
|
Posted: Fri Jul 01, 2005 9:18 am |
|
|
ummm....step 4, thanks Rob! I found a NULL cable at Staples this morning and will try this first. The board came pre wired but thanks for the info Humberto because I should check this too altho TX wiggles as it should.
Sophi |
|
|
Sophi
Joined: 14 Jun 2005 Posts: 64
|
|
Posted: Sat Jul 02, 2005 11:41 am |
|
|
Hi-
I still haven't gotten communications working-
-using NULL modem cable
-reread HTerm. links
while code is running...
MAX232 PIN 2.....+9V
PIN 6......-9V
PIC C6...............HIGH +5V
PIC C7...............???? +3.5V
All is wired as it should be (Thanks Humberto!)
When I look at the serial post (female) end on my Olimex protoboard with the scope, I see no signal at TX (pin 3), but see a signal at the MAX232 pin 12 and also at PIC C6. In case I have the wrong pin number for the serial end I have also looked at every pin and see no signal at the serial end. So how does the signal get into the computer?
Or do I not understand how the MAX chip works? (Yes I read the data sheet).
Thanks-
Sophi |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jul 02, 2005 3:11 pm |
|
|
Quote: | I still haven't gotten communications working-
I am using a Protoboard (Olimex) that comes with a MAX232 chip |
Here is a link to the Olimex website. They have many Proto Boards.
http://www.olimex.com/dev/
What is the model number of the one you have ? If you tell us that,
we can download the schematic for that board from their website
and see what kind of serial cable you need. (ie., normal or null-modem)
We could also find other things related to your problem.
Also, the Olimex boards can have either a 4 or 20 MHz crystal.
Look at the crystal on your board. What frequency is it ? |
|
|
Ttelmah Guest
|
|
Posted: Sat Jul 02, 2005 3:44 pm |
|
|
In answer to the question "what does the Max232 'do'", there are two parts to the answer. Half the chip is a relatively standard inverting driver. It takes an incoming logic signal, inverts it, and drives the output with the result. It also works the other way, taking an incoming voltage signal, and inverting this. However the key thing is that RS232, defines the transmission voltages to be used, as both +ve, and -ve voltages, and somewhat above the 5v normally available on a logic board. The other half of the MAX232, is a set of charge pumps, which work together to generate about +9v, and -9v, from the incoming 5v. It is these voltages that are then used to drive the output of the inverter. The 'spec', says that the unit should give a minimum of +/-5v, and typically +/-8v on the outputs. Now the fact that these voltages are present, says that the output is not shorted out, and the charge pumps are running.
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Jul 03, 2005 8:52 am |
|
|
Quote: |
#include <16c74a.H>
#device ICD=TRUE
|
According with the micro you are using (and the LED in PIN_A0) probably you are
using the OLIMEX PIC P40B Prototype Board. If so, it has a jumper J2 to select
DTR/RTS. Move the jumper to other position and try.
The PIC16C74A doesn�t have ICSP capabilities hence you can�t use it with the ICD.
With the same prototype board you can use the PIC16F877 wich is
pin to pin and ICD compatible.
Keep well,
Humberto |
|
|
Sophi
Joined: 14 Jun 2005 Posts: 64
|
|
Posted: Tue Jul 05, 2005 8:16 am |
|
|
still nothing-
I have changed out the MAX chip and also switched to another board in case either of these are bad.
I am using Olimex PIC P-40 protobaord with a 20mHz crystal.
The only wires I have put on this board are from TX->C6 and RX->C7.
Code is exactly Humberto's above minus ICD header.
I get no signal from the serial end on the Olimex bord, only highs and lows. I get a signal at C6 and on the MAX chip pin 12...shouldn't I see the same thing at the serial end? I am using a pull-up resister to poke in the holes of the serial end to look with the oscilliscope. Have tried this at both +5 and gnd.
Thanks-
Sophi |
|
|
|