Hi
Ive been stumped with a problem for the last two days. I am using a PIC16F690 and trying to do serial communication with it. I am able to successfully send serial out using both HSEROUT and SEROUT, but I cannot get either HSERIN or SERIN to work. I have checked the logic level of my USB to serial adapter using my oscilloscope and it is sending 5V levels into the designated RX pin, but no matter what I try it does not accept any serial characters. Ive tried various baud rates and T vs N (when I was trying to see if I had more luck with SERIN over HSERIN) just in case; no luck. Ive also tried the same code (using only the SERIN command) on a PIC16F1507; again, SEROUT works but not SERIN.
I studied the data sheets for these parts and I cant find anything that I have missed
is there some peculiarity about these chips that I may have missed?
I pasted below one of the HSERIN tests I tried with the F690, based on ME Labs' HSERIN/HSEROUT demo code. In this particular version I commented out their DEFINE HSER_RCSTA 90h and set the SPEN & CREN bits explicitly, just in case. But even without the explicit commands to set those bits and leaving the DEFINE HSER_RCSTA 90h alone as per the example, the serial receiving still doesnt work. It does send the Hello World correctly.
Any suggestions or tips would be very welcome!
Thanks
Alan
Include "modedefs.bas"
DEFINE OSC 8 'define the clock speed so BASIC knows
OSCCON = $FF
ADCON1 = 7
RCSTA.7 = 1 'SPEN = 1
RCSTA.4 = 1 'CREN = 1
TXSTA.4 = 0 'SYNC = 0
' Set receive register to receiver enabled
' DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 20h
' Set baud rate
DEFINE HSER_BAUD 9600
char Var byte ' Storage for serial character
start:
Hserout ["Hello World", 13, 10] ' Send text followed by carriage return and linefeed
low portc.5 LED on
pause 250
high portc.5 LED off
mainloop:
Hserin 10000, start, [char] ' Get a char from serial port
Hserout [char] ' Send char out serial port
Goto mainloop ' Do it all over again
End