PDA

View Full Version : HSEROUT and 16F628A



fredblah
- 3rd May 2004, 07:38
As a newcomer to the micrcontroller world I thought I would get quicker results by using the melabs basic compiler (not reckoning on the quality of the documentation).

I also chose to use a 16F628A thinking that its harware UART might make life easier. I have read section 12 (among others) of the Datasheet for this device pretty thoroughly and have had a good look at the forum. I have also taken a look at the HSEROUT entry in one of the libraries but don't really have enough assembler yet to really come to grips with it (which is why I bought the melabs basic compiler).

I have breadboarded the 16F628A with a MAX232 and checked the circuit twice. In the idle state the voltages on the MAX232 R1in(3.3V) and TXout (-5.3V) look OK. TXout is wired to pin 2 of the serial port on a PC, RXin is wired to pin 3 and Signal Ground is wired to pin 5.

I compiled the following code and uploaded it to the 16F628A.

DEFINE OSC 10 'Using a 10MHz Xtal
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h 'BRGH set for high baud
DEFINE HSER_BAUD 9600 'Doco says use this OR SPBRG
DEFINE HSER_CLROERR 1

LOOP:

HSEROUT ["B"]

GOTO LOOP

END


The result is gobblygook at the PC end. I have tried two serial ports listeners and Hyperterminal and the best I can get is gobblygook, though one of them reports a framing error. I have also tried quite a few variants of the listed code.

The serial port on the pc is definitely working fine as I have another PC successfully outputting strings for another project.

I reckon its time to ask for help before I burn up a lot more time. Hopefully someone will point out some really silly blunder or omission I am making and put me out of my misery.

Any help would be very gratefully received.

Regards,

fredblah

d1camero
- 6th May 2004, 00:07
fredblah, I cannot see anything obvious, although I am not expert. I would try simply using SEROUT2 or DEBUG on a pin directly to the RS-232 (use inverted 2400 8N1). I have done this with a few chips and works well for me.

Once I have that working, then I would move on to the UART, then to the MAX232.

Caution: I am only hooking the uProc pin to the Rx pin on the PC, do not hook the Tx from the RS-232 without some kind of resistor as the TTL level could fry some parts.

d1

P.S. also double check you resonator value.