-
PICKit 2 USART
HI All
I have look on the website (swordfish) where it use PICKIT 2 to Tx/Rx from PC directly using UART Tool.
http://www.digital-diy.net/18F%20Exa...CKit2UART.aspx
I had tried to do it as the website above with the following code. But FAILED!!
On the UART Tool:-
Echo is ON. When I type Hello, the screen only shown Hello Once and does not shown Hello Twice (send and echo). WHY??
Code:
DEFINE OSC 4
' Set baud rate
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
datain VAR BYTE
main:
HSerin [datain]
HSerout [datain]
GoTo main
Thanks
Peter
-
You haven't enabled the serial port according to the PBP manual. All you've done is set the baud rate. That's it. HSERIN/HSEROUT are talking to a register that 'doesn't care' until you set the right DEFINEs.
Have a look, add the code, see what happens.
-
2 Attachment(s)
Hi
I had added in the Define as below. I'm using PIC16F877A and 4 MHz.
I enter "a" and click send. There are nothing echo back. "a" only show once when the echo button is checked.
Any idea???
Code:
DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 6
DEFINE HSER_CLROERR 1
datain VAR BYTE
main:
HSerin [datain]
HSerout [datain]
GoTo main
Any suggestion ???
Thanks
Peter
-
Did you try swapping the Rx/Tx pins on one end?
And while you're at it, try 2400 baud, instead of 9600. Yes, 9600 should work...but 2400 should be a bit more reliable if there are other problems.