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

compiler produce EXTRA?

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



Joined: 02 Oct 2003
Posts: 5

View user's profile Send private message

compiler produce EXTRA?
PostPosted: Tue Nov 11, 2003 6:02 pm     Reply with quote

Hi,

Could you please explain why CCSC produce extra lines:
.................... output_low(PIN_D0);
0166: BSF 03.5 why this line is produced?
0167: BCF 08.0 why this line is produced?
0168: BCF 03.5 I only need this, which set to bank 0
0169: BCF 08.0 I only need this, which is cleared PORTD bit 0

The only 2 bottom lines are the one make sense to me, but I don't understand why the compiler produced the first two lines?

The second question is:
is there the way I can turn on or off the compiler option, so that it produces exactly what I need, I have tried to turn on the level of optimization, but does not help at all.

Thank you for your help
Van
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 11, 2003 7:55 pm     Reply with quote

The compiler is setting the TRISD register. It does this because
it's in Standard I/O mode. That is the default mode.

You can tell the compiler not to set the TRIS register by using
the #use fast_io() directive. But if you do this, then you must
put in a line of code to set the TRISD register. This is done with
the set_tris_d() function. Example:

Code:
#use fast_io(D)    // Tell the compiler to use fast_io on Port D

main()
{
set_tris_d(0xFE);    // Make pin D0 be an output pin   

// Toggle Pin D0 high and low at a 1 KHz rate.
while(1)
  {
    output_low(PIN_D0);
    delay_us(500);
    output_high(PIN_D0);
    delay_us(500);
  }

}
Van



Joined: 02 Oct 2003
Posts: 5

View user's profile Send private message

PostPosted: Wed Nov 12, 2003 10:01 am     Reply with quote

Thank you, PCM
it worked! Very Happy

Van
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