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

9 bits or 8 bits parity=E

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







9 bits or 8 bits parity=E
PostPosted: Tue May 02, 2006 11:13 pm     Reply with quote

Hello

I need some help with a very basic issue. I'm trying to use the following code:

Code:
#include <16F877A.h>
#fuses NOPROTECT, XT, NOWDT, PUT, NOLVP, BROWNOUT
#use delay(clock=3579500)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=9)

char c;

main() {


   setup_adc(ADC_OFF); 
   SET_TRIS_C( 0x80 );

   while (TRUE) {

   c=getc();
   putc(c);
     }

}

It compiles but it doesn't do anything ( once programmed on the PIC). If I try with 8 bits it works fine but with 9 it doesn't .I'm using hyperterminal, and all I want for now is to be able to detect errors. Please help Crying or Very sad
Thanks
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: 9 bits or 8 bits parity=E
PostPosted: Tue May 02, 2006 11:59 pm     Reply with quote

Coni wrote:

It compiles but it doesn't do anything ( once programmed on the PIC). If I try with 8 bits it works fine but with 9 it doesn't .I'm using hyperterminal, and all I want for now is to be able to detect errors. Please help Crying or Very sad
Thanks


Hyperterm only supports 7 or 8 data bits.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Coni
Guest







PostPosted: Wed May 03, 2006 9:32 am     Reply with quote

Thanks for you answer.
But if I want to use 8 bits and even /odd parity ( in hyperterminal) it doesn't work either Sad
Thanks
Javiere
Guest







9 bits or 8 bits parity=E
PostPosted: Wed May 17, 2006 9:16 am     Reply with quote

I have de same problem:

I’ am developing a ModBus slave device and I need work with an interfaz RS-232 at 9600 bauds, 8 data bits, 1 even parity and 1 stop bit.

I utilise the PIC18F4620 with the CCS C compiler version 3.239.

My problem consists in that I can’t detect the parity errors.

My program utilizes the next code:

#use delay(clock=20000000,RESTART_WDT)
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8,enable=PIN_C5,restart_wdt,errors,stream=HOST)
#bit parityError=rs232_errors.0

…….

#int_RDA
void RDA_isr ()
{
if (!parityError)
{
car = fgetc (HOST);
// processCar (car);
}
else
{
fgetc (HOST); // Discard the character.
}
}

With this code the transmission is Ok but in the reception y have a lot of wrong characters that look like good viewing with the oscilloscope.

¿Have you got any example that shows the use of the check of the parity error?

Thank you very much.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 17, 2006 9:44 am     Reply with quote

The parity is calculated in software by the CCS fgetc() function.
So you have to call fgetc() first, in order to get the parity information.
Example:

Code:

#int_RDA
void RDA_isr()
{
int8 car;

car = fgetc(HOST);

if(!parityError)
  {
   // processCar(car);
  }

}
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