if you don't use any HSERIN/HSEROUT you use the second methode, unless you use the DEFINE method.
this one work here
Code:
@ __CONFIG _HS_OSC & _LVP_OFF
DEFINE OSC 20
PORTB=0
TRISB = %00000010
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 129 ' 9600 Baud @ 20MHz, 0.16%
PIE1.5 = 1 ' Enable USART interrupt
start:
if PIR1.5 = 1 THEN ' RCIF FULL?
PORTB.0=1
PAUSE 200
PORTB.0=0
WHILE PIR1.5
TXREG=RCREG ' send it back to the pc
' utill USART buffer is empty
wend
if RCSTA.1=1 THEN ' ANY Overrun?
RCSTA.4=0 ' YES clear it
RCSTA.4=1 '
ENDIF
endif
goto start
just change DEFINE OSC, TXSTA and SPBRG to suite your requirement. Make sure you have a RS232 inverter (MAX232 or else) between your PC and your PIC.
And YES the DEFINE's have to be in capital letter, unless it will never work.
Last edited by mister_e; - 29th November 2007 at 14:24.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks