View previous topic :: View next topic |
Author |
Message |
Van
Joined: 02 Oct 2003 Posts: 5
|
compiler produce EXTRA? |
Posted: Tue Nov 11, 2003 6:02 pm |
|
|
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
|
|
Posted: Tue Nov 11, 2003 7:55 pm |
|
|
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
|
|
Posted: Wed Nov 12, 2003 10:01 am |
|
|
Thank you, PCM
it worked!
Van |
|
|
|