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

How to relocate the software UART code

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



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

How to relocate the software UART code
PostPosted: Wed Apr 21, 2004 6:00 pm     Reply with quote

Hi all
Is it possible to specify the code location for the software UART? I've tried using the #org directive right before #use r232, but the compiler still puts the code wherever it pleases. Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 21, 2004 9:20 pm     Reply with quote

Quote:
Is it possible to specify the code location for the software UART?
You can do it by putting the "Default" parameter at the
end of your #org statement. This tells the compiler to
put internal library code in the #org'ed segment.

You can restore the compiler behavior back to normal
by putting a "#org Default" statement by itself after
after your #org'ed code. This will tell the compiler
that it's OK to put library functions in low ROM again.

In the example below, the software USART code for
getc and putc is in the 0x1800 ROM segment.

The library code for delay_ms is at 0x0004.

This was tested with PCM vs. 3.190.

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

//======================================
#org 0x1800, 0x1FFF  default

char my_function(char c)
{
// Specify a software USART.
#use rs232(baud = 9600, xmit=PIN_B1, rcv=PIN_B0)

char retval;

putc(c);
retval = getc();

return(retval);
}

#org default   // Allow library code to be in low ROM again

//================================
void main ()
{
delay_ms(1);
my_function(0x55);

while(1);
}

Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Apr 23, 2004 2:17 am     Reply with quote

Thank you. The key was to put the #use statement inside the function.
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