View previous topic :: View next topic |
Author |
Message |
gonz
Joined: 20 Nov 2003 Posts: 2
|
Problem with #use rs232 |
Posted: Sat Dec 13, 2003 11:41 am |
|
|
It seems that the "#use rs232" directive causes the CCS compiler to generate hidden code to enable the USART, which apparently occurs before main() is ever called. Enabling the USART drives the TX line high, which is not allowed by the electronics in my application except in specific protocol states.
I tried disabling the serial port as the first line of main(), which reduces the spike to something on the order of microseconds. But is there any way to eliminate that code entirely, but still have access to get() and kbhit() etc.?
-Gonz |
|
|
frankb
Joined: 08 Sep 2003 Posts: 7
|
|
Posted: Sat Dec 13, 2003 12:17 pm |
|
|
Hi Gonz,
You might try adding the FLOAT_HIGH and ENABLE= (pin) options to your #USE rs232 directive. Add a resistor (1K to 10K) between your TX pin and the one you assign as ENABLE. I haven't tried this so I don't know if it will glitch on start up. If there is a glitch, it might get smaller as you decrease this resistor but I wouldn't go much below 1K. Good luck. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 13, 2003 1:19 pm |
|
|
1. First method:
[Edited to remove my 1st suggestion. Upon further investigation,
it didn't work. But hopefully the method below will work for you.]
2. Second method:
You could leave out the #use rs232 statement entirely.
Then, at the appropriate point in your code, put in some lines of code
that initialize the USART by writing directly to the PIC registers.
Read the data sheet, or the .LST file, to see this code.
Also create your own putc and getc routines. These are just a
few lines of C code. See the .LST file to see how CCS does it.
Then use the special CCS extension of printf, to send printf
output to your own version of putc(). By doing so, you
have most of the CCS functionality, but you have done it
without a #use rs232 statement. You would also need to
either hardcode the baudrate value or create a #define
statement to calculate the proper value at compile time. |
|
|
gonz
Joined: 20 Nov 2003 Posts: 2
|
|
Posted: Sat Dec 13, 2003 6:07 pm |
|
|
Quote: | Then use the special CCS extension of printf, to send printf
output to your own version of putc().
|
Hmm that is an interesting suggestion. It would not help in cases of software USART, but then in our experience the software USART is not very reliable anyway. Again and again, I'm finding that I'm better off ditching the runtime library functions and just coding directly to the ports.
Thanks,
-Gonz |
|
|
|