PDA

View Full Version : PIC18F4680 to PC via MAX232 (RS232 serial) no output



opticsteam1
- 14th April 2008, 01:53
I have a PIC 18LF4680 that I'm trying to connect via serial rs232 to the pc. I'm using a MAX232 device to convert the TTL signals to rs232. I happened to have this nifty pre-made rs232 connecting pcb device lying around, so I decided to use that instead of building my own circuit and outputting that to serial, but i'm having difficulty in making it work. I have a feeling that the PIC is outputting correctly, but the max232 is output gibberish to the serial port, which is why its not showing up with anything. But I'm not sure about that. Also there are jumpers on the rs232 device (shown in the schematic attached) but i've just left them disconnected (open) because I only want to use pins 2 and 3 of the female serial port for communcation.

Here is my code for it:


DEFINE OSC 20
DEFINE HSER_RCSTA 90h ' Enable Serial PORT
' Enable continuous receive
'
DEFINE HSER_TXSTA 24h ' Enable transmit
' High baud rate (BRGH=1)
'
DEFINE HSER_SPBRG 129 ' set USART to 9600 baud
DEFINE HSER_CLROERR 1 ' Enable automatic overrun error



Start:
PAUSE 1

HSEROUT ["IT WORKED" ,10,13]

goto start

END


my configuration settings (my pic is connected to a 20MHz resonator):


__CONFIG _CONFIG1H, _OSC_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L


Attached are my schematics for the device and the output from pin 25 of the PIC (the square wave one) and output from pin 13 of the MAX232 device (the distorted looking one). I'm using PicStart Plus to program the device, Microcode Studio to compile it, and MPASM to compile the assembly. I'm using Microcode Studio's Serial Communicator to view any output from COM1 with settings: COM1, 9600 baud, No parity, Byte size is 8, 1 stop bit

Raflex
- 14th April 2008, 05:01
Hello. Invert TX and RX on PIC side.

falingtrea
- 14th April 2008, 20:39
Yup, like Raflex says, you gotta do the null modem thing. PIC RX to PC TX and PIC TX to PC RX. And you gotta make sure the polarities out of the MAX chip are right. But it looks like swapping the RX and TX on the PIC side ought to do it.