CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PCWH 3.249 and Odd Parity generation.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PCWH 3.249 and Odd Parity generation.
PostPosted: Thu Aug 13, 2009 3:09 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:19 pm     Reply with quote

Post your PIC.
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:22 pm     Reply with quote

18lf8622
_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:48 pm     Reply with quote

OK, and what's your #use delay() frequency ? (See why posting a test
program is better. It saves time).
Guest








PostPosted: Thu Aug 13, 2009 6:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 14, 2009 2:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 16, 2009 9:40 pm     Reply with quote

8 data bits and 1 parity bit (9 bits total)
_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 17, 2009 1:22 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 18, 2009 1:23 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group