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

Problem with #use rs232

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



Joined: 20 Nov 2003
Posts: 2

View user's profile Send private message

Problem with #use rs232
PostPosted: Sat Dec 13, 2003 11:41 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 13, 2003 12:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 13, 2003 1:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 13, 2003 6:07 pm     Reply with quote

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
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