View previous topic :: View next topic |
Author |
Message |
PICKYUSER Guest
|
How to send 1 byte of data as: "No Parity, 7-bit, 1stop |
Posted: Tue Mar 30, 2004 6:02 pm |
|
|
I am using PIC18F452 in my application and using RS-232 to communicate with my PC. I don't know howw to output a character as "N71" by using "PUTCHAR". Is there a technique to send a character as N71 with CCS compiler? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
N71 |
Posted: Tue Mar 30, 2004 6:25 pm |
|
|
According to the PIC data sheet it cannot be done in hardware at all.
You can set up the S/W UART (#use RS232) and it can handle N71 bit data. I checked it and it seems to compile and work with no problems.
Good Luck |
|
|
PICKYUSER Guest
|
RE:dyeatman |
Posted: Wed Mar 31, 2004 7:47 pm |
|
|
Hi dyeatman
I check the CCS manual and in the #USE RS232 section, CCS already stated that quote "5-7bits may not be used with internal SCI". Even so, I also tried to set : #USE RS232(.....,bits=7), but this does not work. The outputted data is still 8-bit.
Thanks anyway, |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed Mar 31, 2004 8:20 pm |
|
|
What are your transmit and receive pins? If you use the same pins as the hardware UART then CCS will automatically will use the built-in UART(which doesn't support what you want to do). Try changing the send and receive pins. this should make the compiler create a software UART. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
S/W UART for 7 Bits |
Posted: Wed Mar 31, 2004 8:38 pm |
|
|
Just speculation here since I haven't done it but simply reversing the Transmit and Rcv pins between C6 and C7 should, in theory, cause a S/W UART to be generated for those pins. Anyone kow for sure?? I am going to try to check this....
Dave
Update: I just checked and reversing C6/C7 does generate a S/W UART which should generate N71 if required |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
|
Posted: Wed Mar 31, 2004 9:47 pm |
|
|
Alright folks, this is pure speculation, because I haven't actually tried this, but . . . the serial data is transmitted LSB first, and the stop bit is a 1, so couldn't you just OR your data with 0x80 to set the MSB, aka the last bit, which will be the stop bit for N71, then transmit it as 8 bits. Yeah the stop bit will be long (2 bits minimum), but I haven't run into a situation, yet, where a long stop bit caused a problem.
Try this and see if it works. |
|
|
|