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

complete newbie question

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








complete newbie question
PostPosted: Thu Mar 04, 2004 6:12 am     Reply with quote

How do i read in from ports.

eg.
i want to right a simple program that counts the number of times a switch on rb0 is pressed and display the output in binary on portc.

i'm using a 16f877 thanks.
SteveS



Joined: 27 Oct 2003
Posts: 126

View user's profile Send private message

PostPosted: Thu Mar 04, 2004 8:18 am     Reply with quote

read thru the example programs -

ex_ccp1s.c - shows reading a pushbutton

ex_pbutt.c shows it using interrupts, but you should try polled as a start.

- oh yeah, don't forget about debouncing the switch!

- SteveS
jds-pic2
Guest







Re: complete newbie question
PostPosted: Thu Mar 04, 2004 8:19 am     Reply with quote

Anonymous wrote:
How do i read in from ports.

eg.
i want to right a simple program that counts the number of times a switch on rb0 is pressed and display the output in binary on portc.

i'm using a 16f877 thanks.


set up an interupt on rb0. if there is no HW support to do so you will have to sit and continuously poll the pin. after your overall measurement interval expires, output the value to the target port by employing a #BYTE directive. there are examples of both these issues in the CCS manual.

how will you handle switch debouncing? in HW, SW, or both?

jds-pic2
tong143



Joined: 09 May 2011
Posts: 14

View user's profile Send private message

PostPosted: Fri May 13, 2011 1:55 am     Reply with quote

SteveS wrote:
read thru the example programs -

ex_ccp1s.c - shows reading a pushbutton

ex_pbutt.c shows it using interrupts, but you should try polled as a start.

- oh yeah, don't forget about debouncing the switch!

- SteveS

Please tell me where I can fine the ex_pbutt.c program
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 13, 2011 7:08 am     Reply with quote

It should be in your examples folder. On my PC it is here:
C:\Program Files\PICC\Examples
but the path may vary depending on your compiler installation.

If you are just starting to learn to program you should try polling first, before using interrupts.
_________________
The search for better is endless. Instead simply find very good and get the job done.
tong143



Joined: 09 May 2011
Posts: 14

View user's profile Send private message

PostPosted: Fri May 13, 2011 7:47 am     Reply with quote

Please give me information on where to find literature and examples on polling
tong143



Joined: 09 May 2011
Posts: 14

View user's profile Send private message

PostPosted: Fri May 13, 2011 7:50 am     Reply with quote

Shall you help on topic posted under http://www.ccsinfo.com/forum/viewtopic.php?p=147631#147631

SherpaDoug wrote:
It should be in your examples folder. On my PC it is here:
C:\Program Files\PICC\Examples
but the path may vary depending on your compiler installation.

If you are just starting to learn to program you should try polling first, before using interrupts.
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