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

fast_io on a 12F635 not working- suggestions appreciated....

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



Joined: 12 Jul 2005
Posts: 5

View user's profile Send private message

fast_io on a 12F635 not working- suggestions appreciated....
PostPosted: Thu Jul 21, 2005 9:13 am     Reply with quote

Hello -

I'm not seeing the 1usec pulses when fast_io(A) is invoked, in fact - the output stays low??
The list file claims the bit is being set and cleared in two cycles -
is there something I'm missing?

Thanks for the help,
Albert



//CODE:

delay_ms(200); // delay schedule 2 by 200ms (+ 10ms) //
#use fast_io(A)
output_high(PIN_A5);
#asm
nop
#endasm
output_low(PIN_A5);
#use fast_io(A)

}

//LIST FILE:

.................... delay_ms(200); // delay schedule 2 by 200ms (+ 10ms) //
0085: MOVLW C8
0086: MOVWF 44
0087: CALL 004
.................... #use fast_io(A)
.................... output_high(PIN_A5);
0088: BSF 05.5
.................... #asm
.................... nop
0089: NOP
.................... #endasm
.................... output_low(PIN_A5);
008A: BCF 05.5
.................... #use fast_io(A)
....................
.................... }
Ttelmah
Guest







PostPosted: Thu Jul 21, 2005 9:24 am     Reply with quote

As soon as you enable #use fast_io, it becomes _your_ responsibility to handle TRIS.
After the #use fast_io statement, you need to add the line to tell the pin to be an output. Now you can toggle the pin up/down to your heart's content.
You don't need to use assembler to get a one clock delay. use delay_cycles(1);
You don't say what your clock rate is?. Remeber the actual instruction all take time. As it stands, assuming your clock is running at 4MHz, so 1uSec/instruction, you will see the pin go high for 2uSec. Basically it is set high in the third clock cycle of the output instruction, then there is a four clock delay, then it is set low in the third cycle of the next instruction. Total of eight clock cycles.

Best Wishes
alm1006



Joined: 12 Jul 2005
Posts: 5

View user's profile Send private message

PostPosted: Thu Jul 21, 2005 10:34 am     Reply with quote

The C Compiler reference manual shows the syntax as #use fast_io(port),
the example shown is written as #use fast_io(a), no mention of the tris registers??
It also shows #use fixed_io,#use standard_io,set_tris_X.

Also, why should I have to reset the tris register, it was set initially and was never changed. If I remove the #fast_io comment the output pin works as it should but takes twice the amount of time.

The clock rate is 4mhz. I'm rather new at this so please forgive the newbie mistakes, I have Embedded C Programming and the Microchip Pic
by Richard H. Barnett arriving today.

Thank you for your time and patients,

Regards,
Albert
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 21, 2005 11:50 am     Reply with quote

Quote:

The C Compiler reference manual shows the syntax as #use fast_io
(port), the example shown is written as #use fast_io(a), no mention of
the tris registers??


From the CCS manual, page 62 (page 74 in Acrobat reader),
in the section on #use fast_io:
Quote:
The user must ensure the direction register is set correctly via set_tris_X().
Ttelmah
Guest







PostPosted: Thu Jul 21, 2005 3:53 pm     Reply with quote

The help file also gives a longer description of this. Specifically:
-------
Affects how the compiler will generate code for input and output instructions that follow. This directive takes effect until another #use xxxx_IO directive is encountered. The fast method of doing I/O will cause the compiler to perform I/O without programming of the direction register. The user must ensure the direction register is set correctly via set_tris_X().
-------

Notice the last line.
Now look at the entry for 'standard_io' (the default), and notice it's middle line:
-------
The standard method of doing I/O will cause the compiler to generate code to make an I/O pin either input or output every time it is used.
-------

The I/O pins on the processor all normally 'wake up' as inputs (avoids things being driven that shouldn't be...). The extra time involved in the standard_io form, is because it sets the direction for every operation.

You might want to consider using 'fixed IO' instead. With this, you would declare:
Code:

#use fixed_io(a_outputs=PIN_A5)
output_high(PIN_A5);
delay_cycles(1);
output_low(PIN_A5);


You do not need to 'repeat' the fast_io/fixed_io declaration. If you want the pins to return to normal operation, use #use_standard_io(A) to turn fast/fixed mode off.

With fixed I/O, the declaration includes the list of the pins to be used as outputs, and sets the tris once at the declaration. It then behaves just like fast_io.

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