View previous topic :: View next topic |
Author |
Message |
ssaakmnt
Joined: 03 Dec 2011 Posts: 27
|
creating new port |
Posted: Mon Mar 18, 2013 12:57 pm |
|
|
I am trying to run 4 7segment displays directly from pic16f877 , 3 displays for port b,c and d , port a has not enough pins to drive the 4th display so the idea is to build new port consist of port a pins and port e pins can we do that ? , I tried this code but didn't work: Code: | byte newport;
#bit aa=newport.0;#bit bb=newport.1;#bit cc=newport.2;
#bit dd=newport.3;#bit ee=newport.4;#bit ff=newport.5;#bit gg=newport.6;
#define aa PIN_A1
#define bb PIN_A2
#define cc PIN_A3
#define dd PIN_A4
#define ee PIN_A5
#define ff PIN_E0
#define gg PIN_E1
.
.
.
output_newport(255);// for example |
|
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Mar 18, 2013 1:25 pm |
|
|
Yes you can.
But I feel it's simpler to multiplex.
Frees up loads of pins.
I'm assuming you're using LED displays.
And you've included current limit resistors in each segment lead.
So:-
1) Connect all 4 segments a together to say C0
2) Same for b,c,d,e,f,g,dp to C1,,,,,,C7.
3) Common of display 0 to D0
4) Same for commons 1,2,3 to D1,D2,D3.
Then:-
Turn each display on in turn for say 1ms each.
Can't help further until we know if you're using CA or CK displays.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Mon Mar 18, 2013 2:23 pm |
|
|
aw Mike , he's sooooo close to doing it, no need to mux !!
I did the same thing about 20 years ago when the 877 was new.
Do not use RA4 as it's 'open collector'. Instead use RE2.
Be sure to disable any analog pins though!
There is a thread or two here that explains using combining bits from different ports to become a 'byte' wide 'new' port.
As well it is covered in the CCS C manual,' somewhere'...
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Mar 18, 2013 2:46 pm |
|
|
OK. I'm not going to argue.
Though he could use A4 with CA displays.
Been caught out with that one more than once (wondering why it never goes high).
Mike |
|
![](templates/subSilver/images/spacer.gif) |
ssaakmnt
Joined: 03 Dec 2011 Posts: 27
|
|
Posted: Tue Mar 19, 2013 12:07 pm |
|
|
very good idea to operate all displays from one port each one alone for short period of time..i will try that ,
but also important to know how to combine different port bits to create new port ? I will chick the manual. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
ssaakmnt
Joined: 03 Dec 2011 Posts: 27
|
|
Posted: Wed Mar 20, 2013 4:35 am |
|
|
Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
|