|
|
View previous topic :: View next topic |
Author |
Message |
jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
RS 232 foolishness |
Posted: Wed Sep 27, 2006 5:15 pm |
|
|
I'm using version 3.236 of the CCS compiler and the USB
prototyping board.
I am trying to program the board to talk with a device that has the following settings:
A 9600baud rate and 11 bit frame (1 Start Bit 8 data bits no parity, 2 stop bits)
Am I out of luck using a pic to communicate with the device?
Can set the device up so I am using 2 stop bits?
so far I have tried...
#use rs232(baud=9600, parity = n, bits = 8, xmit=PIN_C6, rcv=PIN_C7)
and using the printf to communicate the required string
Setting bits = 9 didn't seem to work. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: RS 232 foolishness |
Posted: Wed Sep 27, 2006 5:57 pm |
|
|
Deleted.... I misread the original post and thought 9 data bits and two stop bits were required simultaneously. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Last edited by asmallri on Thu Sep 28, 2006 1:07 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 27, 2006 6:32 pm |
|
|
If you use the hardware UART, the following program will transmit
and receive data with two stop bits. You configure the UART for
9-bit data mode and then permanently set the 9th Tx bit to a '1'
by writing to the TX9D bit in the TXSTA register. This 9th bit
becomes the additional stop bit.
It also works for receiving data with two stop bits, because the serial
data comes in LSB first, and incoming 9th bit from the device (which
is a '1', because it's a stop bit) will be put into the RX9D bit in the
RXSTA register in the PIC, and you can just ignore it.
I tested this program with Hyperterminal and the Win3.1 terminal
program, with both of them configured for 9600N82, and they both
worked OK. I also saw the 2nd stop bit on an oscilloscope.
For that test, I just did putc(0x55) in a loop, without the getc().
Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=9, ERRORS)
// These register addresses are for a 16F877.
#byte TXSTA = 0x98
#bit TX9D = TXSTA.0
//====================================
void main()
{
char c;
TX9D = 1; // Setup for a 2nd stop bit
while(1)
{
c = getc();
putc(c);
}
} |
|
|
|
jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
RE: RS232 Foolishness |
Posted: Thu Sep 28, 2006 9:13 am |
|
|
I'm a bit confused with the post by PCM Programmer,
The chip you've used has addressable UART so that the TXSTA has an address of 98h.
I'm using the 18F4550 which has enhanced UART and apparently no fixed address for TXSTA?
This is my first attempt to use a pic so I'm quite inexperienced, any elucidation would be appreciated thanks. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Sep 28, 2006 9:41 am |
|
|
0xFAC
spec pg68 |
|
|
jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
Thanks |
Posted: Thu Sep 28, 2006 2:21 pm |
|
|
That works beautifully thanks alot! |
|
|
|
|
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
|