PDA

View Full Version : Debug with parity?



cmolson
- 2nd December 2005, 16:47
Hello again! I have figured out the problem with the inverting of the bytes which I had before. It was one of those cases where the answer is starring you in the face but you are too tired to see it. Now I think I got myself into somthing too deep. Here is what I need to do:


Send data serially at 9600bps with odd parity.
Using a pic 16F84A
Data must be sent on portb.7
Oscillator is fixed at 3.579mhz

Now using debug i am able to send data perfectly and recieve at 9600 baud using 3.579mhz. however the problem comes in when I have to use parity. Is there any way to set parity using debug? I looked throught the manual and found all the other DEFINE's for debug, but there isn't one for parity.

Update:

I have tried serout and serout2, both do not function proporly on my pic at 9600baud. Is there a way to speed them up by defining static port and baude?

I'm thinking of maybe of an assembly routine to transmit the data.... I would just like some ideas to overcome this, not actual code.

BertMan
- 2nd December 2005, 17:42
Debug can only be used 8N1 (8 bits, no parity, 1 stop bit). To send data with parity, you need to use SEROUT2. You need to make sure you have your DEFINE OSC 3.58 statement. Unfortunatley, at speeds higher than 9600, you will need a faster crystal, and that is probably what is causing you problems.

cmolson
- 2nd December 2005, 18:01
Thats the problem I am facing. I do not have control of the Oscillator or the baud rate or parity. I tried serout2 and it is too slow to handle (also serout) at 9600bps and 3.579mhz. I have teseted the PIC at 10mhz and it can output 9600bps using serout without a hitch, unfortunatly the crystal is fixed at 3.479mhz.. grrr

I have written the code for my applciation and it works perfectly when using no parity... I wish there was a way to send 1 bit out serially after each transmission of a byte with odd parity. I guess the question would be, does anyone think it wouldn't be too hard to create an assembly routine which sends a parity bit serially depending on the byte to be transmitted?

cmolson
- 2nd December 2005, 18:50
One method I saw which seems very basic, is to simply output the bits of each byte and use a pauseus 104 to generate 9600 bps. this way I could send the parity bit. For receivein i do the same thing except I can simply discard the parity bit. This is eally annoying since the parity bit isnt the last i can't simply discard it.

Reven
- 3rd December 2005, 00:23
One small question. How can I use 2 stop bit?
Now I use in my code 7E1 and I want to use 7E2.
Thanks!!