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

FAST I/O

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



Joined: 18 Dec 2009
Posts: 27

View user's profile Send private message Send e-mail

FAST I/O
PostPosted: Thu Jun 26, 2014 10:06 am     Reply with quote

Hello All

i am facing a problem in executing a code

i am using PIC16F876 with 16MHz crystal
when ever i wrote the lines

output_high(PIN_C5)
output_low(PIN_C5)

now the pulse remains high for 1us. and then goes low
is their any other function so that the pulse remain high for just 250ns instead of 1us

as i am not using any delay in between both lines

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Thu Jun 26, 2014 10:54 am     Reply with quote

You have answered yourself, in your post name.....

#USE FAST_IO

However remember that _you_ then have to set the TRIS for the port yourself.

By default, the compiler uses 'standard_io'. In this mode, _it_ will set the tris for each bit as it is used.
So each output instruction gets replaced with 'set the tris for the bit'. 'Set the bit'. Because on your PIC, the TRIS register is in a different page to the I/O register, this involves a bank switch as well. Hence the time.

So if you specify #use FAST_IO for port C, the extra TRIS instructions are removed. However you are then going to have to set the TRIS for every other bit on PORTC, and do it correctly.

Best Wishes
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Thu Jun 26, 2014 11:30 am     Reply with quote

Agreed with the FAST_IO. However I think the OP will end up with 500ns instead of 250. Had the same problem in a dsPIC33 running with a 25ns instruction time, took 50ns to switch the port with fast_io. Lived with it.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Fri Jun 27, 2014 7:53 am     Reply with quote

He should get 250nSec.

For the single bit output, the compiler will use bit set/reset instructions, which are single instructions.
So it'll become a bit set, followed by a bit clear.
Since the actual pin update is at the same point in the instruction in each case, 250nSec at his 4MIPS.
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