PDA

View Full Version : USART SPI problem !



TripleS
- 16th October 2007, 00:08
Hi,

I am new to this forum and I have been reading some of the posts and it seems that there are a lot of knowlegeable and helpful people.

I am currently working on a project that involves using the USART on a pic16F876a with the function HSEROUT. I wrote a simple program in PICBASIC using the HSEROUT command to send a HEX value to a PC's serial port. I am using a serial port monitor program on the PC that can receive and send data. The problem is that the pic16f876a sends a hexadecimal value (ex. $FF) to the PC and the PC receives a different HEX value. This is the code I wrote:

@ device pic16F876a, hs_osc ' oscillator selection
@ device pic16F876a, hs_osc ' oscillator selection
@ device pic16F876a, wdt_off ' watchdog timer
@ device pic16F876a, pwrt_off ' power-up timer
@ device pic16F876a, bod_off ' brown-out reset
@ device pic16F876a, lvp_off ' low-voltage programming
@ device pic16F876a, cpd_off ' data eeprom protection _off
@ device pic16F876a, wrt_off ' flash program memory write
@ device pic16F876a, protect_off ' program code protection _off


define OSC 20

workA VAR BYTE

DEFINE HSER_BAUD 9600 ' Select the baud rate
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_SPBRG 129

char var byte ' Storage for serial character


loop:
pause 200

HserOUT[HEX $FF]

goto loop

I am using a 20MHz crystal. If anyone could take a look at the code I would appreciate any suggestions as to what could be wrong. Thank you in advance for your response.

TripleS

TripleS
- 16th October 2007, 22:09
Anyone? Please??? :(