|
|
View previous topic :: View next topic |
Author |
Message |
Coni Guest
|
9 bits or 8 bits parity=E |
Posted: Tue May 02, 2006 11:13 pm |
|
|
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
Thanks |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: 9 bits or 8 bits parity=E |
Posted: Tue May 02, 2006 11:59 pm |
|
|
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
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
|
|
Posted: Wed May 03, 2006 9:32 am |
|
|
Thanks for you answer.
But if I want to use 8 bits and even /odd parity ( in hyperterminal) it doesn't work either
Thanks |
|
|
Javiere Guest
|
9 bits or 8 bits parity=E |
Posted: Wed May 17, 2006 9:16 am |
|
|
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
|
|
Posted: Wed May 17, 2006 9:44 am |
|
|
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);
}
} |
|
|
|
|
|
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
|