16f877 portc.6 & portc.7


Closed Thread
Results 1 to 22 of 22
  1. #1
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113

    Question 16f877 portc.6 & portc.7

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    trisc = %0000000

    Should do it. What else is in your code?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Post My current code for testing purposes.

    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

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Well I do not see the problem.

    Try this and see what happens.

    Code:
    LOOP:
    HIGH PORTC.6
    HIGH PORTC.7
    PAUSE 100
    LOW PORTC.6
    LOW PORTC.7
    PAUSE 100
    GOTO LOOP
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Still nothing

    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

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavyJones View Post
    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)?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default More information...

    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.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  9. #9
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default got it....thanks skimask

    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

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavyJones View Post
    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.

  11. #11
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Smile So it's just not me then?

    Quote Originally Posted by skimask View Post
    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

  12. #12
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavyJones View Post
    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.
    Dave
    Always wear safety glasses while programming.

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    You should see some of my boards. End up looking like a wire-wrap project with a little etching.
    Prime examples of .... YUK!!!!..... right here...
    http://web.ndak.net/jdgrotte/mp3play...rpicsmain.html

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Mine do not look so bad now.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Smile my 2 little pins seems a pitance

    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/...ures/2007\Pool Alarm Project/

  16. #16
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default Oops try this link... I hope this works


  17. #17
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  18. #18
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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.
    Last edited by BobK; - 11th January 2008 at 21:23. Reason: Extra thoughts

  19. #19
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobK View Post
    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
    Dave
    Always wear safety glasses while programming.

  20. #20
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Smile WooHoo!

    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

  21. #21
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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

  22. #22
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    <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
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 08:14
  2. Help SERIN2/SEROUT2
    By mike20200 in forum mel PIC BASIC
    Replies: 3
    Last Post: - 5th September 2007, 06:19
  3. serial communication between CMUcam and PIC 16F877
    By gengkeys in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th March 2007, 06:43
  4. 4 Quadrant dc drive with 16F877
    By mns45 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 23rd February 2006, 13:05
  5. problem using 16f877
    By yrch in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th February 2006, 18:58

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts