PDA

View Full Version : Even Parity



Andre_Pretorius
- 16th July 2007, 18:59
I am trying to do 8 data bits with even parity, if i use the program below it works fine when i work with 7 data bits and even parity but seems to fail as soon as i go to 8 bits with parity, any suggestions

CMCON = %00000111 ;Disable Comparator module's
OPTION_REG = %11010111 ;Set PIC options
INTCON = 0 ;Disable interrupts
TRISB = %00000010 ;RB1(RX) as input, others to Output
TRISA = 255 ;SET PORTA AS INPUTS

DEFINE OSC 8 ; set oscilator speed to 8mHz
DEFINE HSER_RCSTA 90h ; Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ; Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 12 ; 9600 Baud @ 8MHz, 0.16%
DEFINE HSER_CLROERR 1 ; Clear overflow automatically
DEFINE HSER_BITS 9
DEFINE HSER_EVEN 1

PORTB.4 = 1
DATAIN VAR BYTE[8]
loop
HSERIN [str DATAIN\8]
HSEROUT [str DATAIN\8]
goto looP
END

Darrel Taylor
- 17th July 2007, 03:31
Hi Andre,

I think it's a conflict with the DEFINE's.

For 9bit reception, PBP needs to set a bit in RCSTA and TXSTA, but you've already specified what those values should be, so it can't.
You could change the values of the 2 defines, But why. It's easier to let PBP figure things out.

Try it like this ...
DEFINE OSC 8 ; set oscilator speed to 8mHz
DEFINE HSER_BAUD 9600
DEFINE HSER_BITS 9
DEFINE HSER_EVEN 1
DEFINE HSER_CLROERR 1 ; Clear overflow automatically

Andre_Pretorius
- 17th July 2007, 16:48
Thank you it works fine