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 support@ccsinfo.com

ccs instructions

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



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

ccs instructions
PostPosted: Wed Mar 10, 2004 7:10 am     Reply with quote

Does anyone know if you can put literal values in registers instead
of calling functions all the time??

e.g

set_tris_d(0x00); //calls a function

trisd(0x00); // literal value, no function called, faster execution

-------------------------------------------------------------------------

I think that you would have to amend the header file.
Any ideas??
_________________
Best Regards
Ttelmah
Guest







Re: ccs instructions
PostPosted: Wed Mar 10, 2004 7:29 am     Reply with quote

asjad wrote:
Does anyone know if you can put literal values in registers instead
of calling functions all the time??

e.g

set_tris_d(0x00); //calls a function

trisd(0x00); // literal value, no function called, faster execution

-------------------------------------------------------------------------

I think that you would have to amend the header file.
Any ideas??

Have you looked at the assembler generated?. In fact CCS, does not 'call a function' for most simple operations. So if you execute 'output_b(20)', the assembler generated, is just to load the W register with the value (20), and then to output it to the port (provided you have fast_io selected). The 'set_tris_d' that you quote, will do the same.
You can generate exactly the same code, by using the #byte operation if you really want to, so (of a 18Fxx for instance), you could code as:

#byte TRISD=0xF95

TRISD=0;

The resulting assembler though is exactly the same, and you will gain nothing in speed.

Best Wishes
Chas
Guest







Except set_tris_c()
PostPosted: Wed Mar 10, 2004 8:44 am     Reply with quote

Most of the time you can set registers directly, but watch out the the TRISC register. There can be a problem with "read-modify-write" on that register. As suggested by Microchip, CCS maintains a mirror of the TRISC register which they "r-m-w" and then copy the whole register to the TRISC register. Refer to the section in the data sheet on the I/O ports, such as 3.3 in the 877 manual.

I would also recommend using the built in functions to set the OPTION register. There is a specific routine that Microchip recommends following to change the assignment of the WDT/Timer0 prescaler. CCS does this with the setup_counters() and setup_timer_0() functions. I don't have my compiler here so I may have spelled these two functions wrong but you can find them in the help. This problem is detailed in the mid-range micro reference manual from Microchip in section 26.
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