PDA

View Full Version : Synchronous USART problems... HELP!!!



moni
- 25th October 2003, 10:09
Hi Folks,

I have looked and nobody seems to ever approached the Synchronous high speed issue, so here's a little challange:

I am trying to transmit a string SYNCHRONOUSLY using HSEROUT with no luck.

after reading MicroChip's docs, it seems that the SPEN,SYNC and CSRC bits must be set, so I tried:

DEFINE HSER_SPBRG 59 ' BAUD RATE = 83.333 KBAUD
DEFINE HSER_RCSTA 20h '
DEFINE HSER_TXSTA 90h ' sets CSRC and SYNC bits
DEFINE HSER_CLROERR 1 ' just in case of overflow

and then some hserout commands like this one:
HSerout [$11,$12,$13,$23,$34,$43,$81,$13,$3A]

right after that I had a LCDout command for debugging purposes.

THE PROGRAM NEVER GOT TO THE LCDOUT PART!!! nothing happend. no serial output, no clock, nothing!
so I started REM'ing out the defines one by one. the problem was the DEFINE HSER_TXSTA 90h. I have changed it to 20h just to be sure,
and of course it worked, but Asynchronously.

Am I doing something wrong or HSERout is limited to Async???

Please show me the light!

Thanks

M.M.
New York

moni
- 25th October 2003, 10:12
PS I am using a 20mhz xtal, the pic is a 16F628 on a LAB-X3 board, and yes, the baud rate is 83.3333 kbaud, which is a can-bus sub-standard.

tnx!

M.M.

Kypros
- 28th October 2003, 09:22
Hi,
First, you must include a DEFINE OSC 20 .
Second, the line HSerout [$11,$12,$13,$23,$34,$43,$81,$13,$3A]
I thing does not work like this, put
HSerout ["11121323344381133A"] instead.

Regards
Kypros

moni
- 28th October 2003, 21:00
Kypros,

Tnx for the reply, but I do have DEFINE OSC 20.


and there is no problem using
HSerout [$11,$12,$13,$23,$34,$43,$81,$13,$3A]

it's a standard hex serial out format (look at the PBP manual)

electronicsuk
- 6th November 2003, 07:34
Possibly you're causing an overflow error? Although I don't see why that would halt the program.

Matthew

johnramsbottom
- 13th November 2003, 19:32
Moni, I'm not sure which PIC you're using. I'm used to using the USART on the 16F7XX series but I don't think the associated registers differ much. Are you setting TXEN? This is bit 5 in TXSTA register. You could just put a hex value of B0h into TXSTA (to set CSRC and SYNC also). Also your value of 20h for TXREG seems a bit odd. Surely you need 80h in RCSTA.

Hope you get somewhere.

John R

johnramsbottom
- 14th November 2003, 18:57
Sorry, I meant to say RXSTA and not TXREG, but you probably realised. I'm confusing the issue!

John R

johnramsbottom
- 14th November 2003, 19:00
Sorry I 'm still wrong. I meant RCSTA and not TXREG in my original reply.