View previous topic :: View next topic |
Author |
Message |
Guest
|
complete newbie question |
Posted: Thu Mar 04, 2004 6:12 am |
|
|
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
|
|
Posted: Thu Mar 04, 2004 8:18 am |
|
|
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 |
Posted: Thu Mar 04, 2004 8:19 am |
|
|
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
|
|
Posted: Fri May 13, 2011 1:55 am |
|
|
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
|
|
Posted: Fri May 13, 2011 7:08 am |
|
|
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
|
|
Posted: Fri May 13, 2011 7:47 am |
|
|
Please give me information on where to find literature and examples on polling |
|
|
tong143
Joined: 09 May 2011 Posts: 14
|
|
Posted: Fri May 13, 2011 7:50 am |
|
|
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. |
|
|
|
|