View previous topic :: View next topic |
Author |
Message |
pfournier
Joined: 30 Sep 2003 Posts: 89
|
PCWH 3.249 and Odd Parity generation. |
Posted: Thu Aug 13, 2009 3:09 pm |
|
|
While supporting some old code, I realized that even though I ask for ODD parity in the code.
Code: |
#use rs232(baud=SERIAL2_BAUD, xmit=PIN_G1, rcv=PIN_G2, ERRORS, parity=O, bits=8, stream=SERIAL2)
|
The serial output always has the parity bit at zero.
As a result I have had to generate and insert my own parity bit.
Is there something I don't know? _________________ -Pete |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 13, 2009 3:19 pm |
|
|
Post your PIC. |
|
|
pfournier
Joined: 30 Sep 2003 Posts: 89
|
|
Posted: Thu Aug 13, 2009 3:22 pm |
|
|
18lf8622 _________________ -Pete |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 13, 2009 3:25 pm |
|
|
You know how I work. I make a test program and look at the .LST file.
Please post the #define statement for this: SERIAL2_BAUD |
|
|
pfournier
Joined: 30 Sep 2003 Posts: 89
|
|
Posted: Thu Aug 13, 2009 3:37 pm |
|
|
I know it's not a "normal" value, but I didn't choose it, I just have to live with it.
Code: |
#define SERIAL2_BAUD 312500
|
_________________ -Pete |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 13, 2009 3:48 pm |
|
|
OK, and what's your #use delay() frequency ? (See why posting a test
program is better. It saves time). |
|
|
Guest
|
|
Posted: Thu Aug 13, 2009 6:43 pm |
|
|
10,000,000
I'm now doing this from home and I won't be back until Monday, so I'm working from memory.
I thought it would be a much simpler question. I assume you are aiming toward something so I'm willing to go on if you are. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 14, 2009 2:17 pm |
|
|
I have a question about your Com format. Do you want:
7 data bits and 1 parity bit (8 bits total)
or
8 data bits and 1 parity bit (9 bits total) |
|
|
pfournier
Joined: 30 Sep 2003 Posts: 89
|
|
Posted: Sun Aug 16, 2009 9:40 pm |
|
|
8 data bits and 1 parity bit (9 bits total) _________________ -Pete |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 17, 2009 1:22 pm |
|
|
This test program should work. It tests the parity bit generation.
Look at the output on your oscilloscope. Compile it with one of the two
lines in the while() loop. The parity bit is at the end of the data bits
(on the right side). It's the last bit before the stop bit. The data bits
come out LSB first.
Code: | #include <18F8622.h>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=10000000)
#define SERIAL2_BAUD 312500
#use rs232(baud=SERIAL2_BAUD, xmit=PIN_G1, rcv=PIN_G2, parity=O, bits=8, stream=SERIAL2)
//======================================
void main(void)
{
while(1)
{
// fputc(0x01, SERIAL2);
fputc(0x03, SERIAL2);
}
} |
|
|
|
pfournier
Joined: 30 Sep 2003 Posts: 89
|
|
Posted: Tue Aug 18, 2009 1:23 pm |
|
|
OK,
This made it obvious, my routines have been writing directly to the transmit register! Using fputc fixed that.
I should have realized that since you have to write to the txsta register to set or clear parity that writing directly to the transmit register (txreg), no one else but me was going to be writing the parity register.
It's oh so clear in hindsight.
My device still prefers my direct writes for some reason, but that is another matter that I'm sure I'll figure out.
Thanks for the help. _________________ -Pete |
|
|
|