PDA

View Full Version : 16f877 portc.6 & portc.7



DavyJones
- 11th January 2008, 00:29
hello all. I've got a question I hope will give me the answer I am looking for. Is there anyway to initialize portc.6 and portc.7 on the 877 to use as simple outputs to light a couple led's? I'm hoping I won't have to etch another board. I know I should have looked before I did that but I didn't now I'm stuck. trisc = %0000000 seems to initialize the first 6 portc.0 through portc.5 and I can trigger those to light led's but 6 and 7 won't. I'm sure it's because they are typically used for txd and rxd. I'm hoping there is a way.
Thanks in advance
David

mackrackit
- 11th January 2008, 00:35
trisc = %0000000

Should do it. What else is in your code?

DavyJones
- 11th January 2008, 00:54
Thanks for the response.
I wrote this little test after I realized I used those pins. When this is running led's 0 through 5 will turn on for .5 seconds then go off. but 6 and 7 stay off.

Define ONINT_USED 1
i var byte ' Define loop variable
TRISC = %00000000 ' Set PORTD to all output
FOR I = 0 TO 7
PORTC.0[I]=1
NEXT I
LOOP: Pause 1000
For i = 0 to 7 ' Go through For..Next loop 7 times
PORTC.0[I] = 0
Pause 500
PORTC.0[I] = 1 ' Delay for .5 seconds
Next i
Goto loop ' Go back to loop and blink LED forever
End

mackrackit
- 11th January 2008, 02:19
Well I do not see the problem.

Try this and see what happens.



LOOP:
HIGH PORTC.6
HIGH PORTC.7
PAUSE 100
LOW PORTC.6
LOW PORTC.7
PAUSE 100
GOTO LOOP

DavyJones
- 11th January 2008, 11:52
mackrackit thanks for the assistance

I tried the HIGH PORTC.6 and LOW PORTC.6 loop and still nothing the led's remain off. I don't need to have an pull up or pull down resisitors on those pins do I?

Thanks
David

mackrackit
- 11th January 2008, 12:08
need to have an pull up or pull down resisitors on those pins do I?

No, the LED with its resistor takes care of that.
Now I have to ask the ...
Are you sure you are using the correct pins?
Have you checked the LEDs?
and so on...

With TRISC set for out or in, these to pins act as far as I know like any other, The TX/RX has to be defined.

Can you post you layout(schematic or picture)?

DavyJones
- 11th January 2008, 13:59
mackrackit, For my testing purposes trying to figure this out I am using:
a controller I purchased from http://www.futurlec.com/PIC16F877_Controller.shtml
and led array is http://www.futurlec.com/TrainingBoardAccessories.shtml

You know I feel so stupid not looking more closely at this board. I don't have the schematic and I just assumed that pins 25 and 26 were ported to the header for portc.

I just looked up the boards schematics
http://www.es.co.th/Schemetic/PDF/ET-BASE-PIC40.PDF
and it appears that quite clearly that 25 and 26 have been routed to an rs232 header on the board and the portc header has NC marked clearly on c.6 and c.7 and I'm going to assume that NC is "no connect", well I shouldn't do that should I? hehe if you look at the document you'll see what I mean.

I do appreciate your help answering my questions and getting me thinking more clearly. I'm at the office right now I'm going to check this out as soon as I get home. I should be able to do a quick test by placing a couple led's on that rs232 header on the main controller. Then it should be simple enough for me to route the 2 pins to the portc header were I actually need them.

I'll let you know how it turns out.

skimask
- 11th January 2008, 14:04
Quick look at that datasheet tells me that all you'd have to do is run a jumper across pins 8-9 and 7-10 on the MAX232...if what you're really looking for is to run the RS232 header directly from the PIC at TTL levels instead of RS232 levels.

DavyJones
- 11th January 2008, 14:27
yep thats exaclty what I want to do. Shame on me for not looking at the datasheet first and assuming that the header for portc was connected. What I am going to do is modify that and run jumpers so I can actually use the portc header pins for 6 and 7. I've already have my board etched. I think it should be easy enough.

Thanks
David

skimask
- 11th January 2008, 16:00
I've already have my board etched. I think it should be easy enough.
Thanks
David

For the last few years or so, when I get PCBs done up for me by an outside company, I am ALWAYS putting in loads of extra thru-vias, at the PICs pins, at the components, on long runs, etc.etc. (except on things like crystal traces and anything really sensitive to spikes)
If I find a mistake, all I gotta do is cut a trace, and install jumpers across whatever via's fix the problems.
Sometimes I've got what looks like thousands of via's, but it works.

DavyJones
- 11th January 2008, 17:40
If I find a mistake, all I gotta do is cut a trace, and install jumpers across whatever via's fix the problems.
Sometimes I've got what looks like thousands of via's, but it works.

I'm glad it's not just me. I don't have allot of experience and I probably don't work on allot of projects but the ones I do no matter how careful I am I end up overlooking something. For this project I completely overlooked the fact the the ttl logic was not going to be enough to drive my 9v siren. Jeeze I know I'm no electrical engineer but what was I thinking!

Thanks again
David

mackrackit
- 11th January 2008, 18:05
I'm glad it's not just me. I don't have allot of experience and I probably don't work on allot of projects but the ones I do no matter how careful I am I end up overlooking something. For this project I completely overlooked the fact the the ttl logic was not going to be enough to drive my 9v siren. Jeeze I know I'm no electrical engineer but what was I thinking!

Thanks again
David

You should see some of my boards. End up looking like a wire-wrap project with a little etching.:eek:

skimask
- 11th January 2008, 18:38
You should see some of my boards. End up looking like a wire-wrap project with a little etching.:eek:

Prime examples of .... YUK!!!!..... right here...
http://web.ndak.net/jdgrotte/mp3player/plly4builduppics/playerpicsmain.html

mackrackit
- 11th January 2008, 18:47
Mine do not look so bad now.:)

DavyJones
- 11th January 2008, 19:45
I don't feel so bad either. I guess I only have 2 pins to re-route I should keep my mouth shut hehe.

I think this board actually turned out quite nice considering it's a complte do-it-yourself'er

http://www.jonzilla.com/thebittners/dispphotos.asp?path=pictures/2007\Pool Alarm Project/

DavyJones
- 11th January 2008, 19:47
http://www.jonzilla.com/thebittners/dispphotos.asp?path=pictures/2007\Pool%20Alarm%20Project/

skimask
- 11th January 2008, 20:23
http://www.jonzilla.com/thebittners/dispphotos.asp?path=pictures/2007\Pool%20Alarm%20Project/

The board looks just fine to me, better than I've ever etched myself (see those earlier pic's?)
Only comment I've got about it is...those 90 degree angles... PCBs and 90 degree angles don't mix, especially if you've got any sort of high frequency running across the traces. Double 45 degree angles back to back with a small chunk of straight line at least twice as long as your trace is wide is MUCH better electrically than a single 90 degree corner. Why does it work? The short and simple answer is that the signal can't bounce back down the same path from which it came. Good enough for me and it's worked since I started doing it.

BobK
- 11th January 2008, 21:20
Since now one else caught it I will say it. Your TRISC = %0000000 should be TRISC=%00000000. That's 8 zeros for the 8 outputs. Your statement only had 7. I'm sure it was a minor detail but it had something to do with portC.7.

HTH,

BobK.

Yep no matter how careful you are with your pcb design, you always miss something. When I worked at a electronics place doing projects for the Navy we were not allowed to check our own work but when you are the only person working on your hobby project, it's kind of hard to have someone else check your work.

mackrackit
- 11th January 2008, 21:51
Since now one else caught it I will say it. Your TRISC = %0000000 should be TRISC=%00000000. That's 8 zeros for the 8 outputs. Your statement only had 7. I'm sure it was a minor detail but it had something to do with portC.7.


Darn bifocals:)

DavyJones
- 11th January 2008, 23:46
I got home this evening and soldered in the jumpers and woosh it worked like a charm. My led's are lighting up like the 4th.

Thanks for the advice on the 90's I'll certainly remember that with my next project. Not sure what that will be but this one certainly has been fun. Also good catch on my trisc statement I did not see that, I do wear bifocals just as an fyi. Got them around the time I turned 44.

This project has certainly been a learning experience and I'd have to say overall saved me a good sum of $$$ too. We put in a swimming pool last year and our local code said we had to have each door and each screen door have an alarm that sounds when you gain access to the pool area. I have 9 doors including the screens. The little gizmo's you can get at the pool store were $50 each that would have cost me $450 and they were unsightly. This controller and the the board I etched worked great and after installing the reed switches in the door with a friend one weekend I'm probably only into this for about $75.

Thanks everyone for your help. Not sure what I am going to work on next. I've got a second controller trying to think of something fun to make with it.

Cheers
David

BobK
- 12th January 2008, 02:05
Hi DavyJones,

I wear trifocals and each time I set a binary statement I go back and count the number of digits. Then I saw someone recently on the PBP forums doing this:

<pre> ' 76543210<br> TRISC= %00000000</pre>Seems to take the guesswork out of huh?

Glad you enjoyed your project! There's alot of valuable information on these forums and alot of great people helping each other out.


BobK

paul borgmeier
- 12th January 2008, 04:38
<pre> ' 76543210<br> TRISC= %00000000</pre>Seems to take the guesswork

you got to be careful but in this case

TRISC = %0

is exactly the same as

TRISC=%00000000

zero is still zero

glad you solved your problem