PDA

View Full Version : HSERIN and PIC18F24k22 hanging



jimseng
- 12th July 2012, 17:56
Hello all.
I have my Raspberry Pi talking to my PIC via UART. When the Pi boots it sends out loads of console guff and I have to power cycle my PIC to get it to start receiving proper data. All I am doing is sending three bytes from my Raspi and setting three hpwm channels based on that data. Also, if I send the data too fast (i.e.too much data) the PIC stops responding. I don't know if it is a buffer over run but I thought I had set that to clear automatically.

Anyway, I set the PIC up like this:

DEFINE OSC 16
DEFINE HSER_RCSTA 90h ' enable serial port,
'define HSER_TXSTA 24h ' enable transmit,
define HSER_SPBRG 25 ' set baudrate to 9600
Define HSER_BAUD 9600
'DEFINE HSER_CLOERR 1 ' automatic clear overrun error
DEFINE HSER_CLEAR = ON

And this is all my code is:

START:
hSERIN [ r, g, b]
serout portA.2,6, [#r,#g,#b] 'to test what the PIC thinks it saw
hpwm 1,r,500
hpwm 2,g,500
hpwm 3,b,500
GOTO START

I thought that I had read that DEFINE HSER_CLOERR 1 and DEFINE HSER_CLEAR = ON were the same thing. Perhaps I got that wrong. Anyway. Is there some better handling of Hserin that I should be doing? This is my first attempt at Hserin so I would appreciate some help.

Cheers