12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Cheers Joe, very interesting that regards the GPIO.0 computed GOTO. You can see why a newbie like me got a little confused, very handy piece of code though, thanks for the explanation.

    I had a look at Melanie's Olympic timer, very impressive. She's one very clever lady.

    I've always been an admirer of clever people.

    Right, I'm off to my bed to dream of COUNTER - IF-THEN- ELSE IF commands.

    Really enjoying this, I hope I'm not driving you all to mad?

    David

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


    Did you find this post helpful? Yes | No

    Default

    I hope I'm not driving you all to mad?
    Already been there. Had a lot of fun too!!!!
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Just in case this isn't clear already....
    Code:
    IF GPIO.0 = HIGH THEN  UNLOCK
    This is NOT how you you determine if an input is high or low. HIGH and LOW are commands that both sets the pin in question to "output mode" and then drives it either high or low. To check if a pin (or any bit in any register) is set you do either:
    Code:
    If GPIO.1 = 1 THEN GOTO Unlock
    Or
    Code:
    If GPIO.1 THEN GOTO Unlock
    Or
    Code:
    If GPIO.1 = 0 THEN
      GPIO.2 = 1
      Goto DoThis
    ELSE
       Goto Unlock
    ENDIF
    Right, back to HIGH and LOW... as have been said already the HIGH and LOW commands first sets the pin to "output mode" and then drives the pin high or low. It's nothing wrong with that except that it sets the pin to "output mode" each and every time either command is used. It doesn't matter if the pin already IS in "output mode" - it still writes to the TRIS register - every time and this wastes both time and codes space. It's much better to set the TRIS register manually and only change it if needed and then simply write to the Port or GPIO register directly.

    /Henrik.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi Henrik, thanks for that. Being new to programming it's easy to get confused especially when many of the terms are so similar.

    I'm a relatively slow learner too which doesn't help I guess. When I finally get it though, it does stick.

    You've got to marvel the complexity contained within an eight pin microchip, staggering.

    I can't wait to actually build something either.

    Have a nice evening.

    David

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi everyone.

    I'm working on my first circuit using the12F683 and I'd like to add a push button as an input. Would I be right in assuming that:

    A pull-up resistor say 10k from the +5v line onto the chosen input GPIO.n and a push button connected from GPIO.n to ground should do the job?

    This to my mind would leave GPIO.n at +5v until pressed, momentarily dropping to 0v.

    David

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


    Did you find this post helpful? Yes | No

    Default

    Yup, that will work.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Cheers mackrackit.

    My project, here's the master plan:

    I'm going to use the 12F683 to output 4 bit words to drive a BCD to 7-segment decoder driver: Count up from 0-9 in a continual loop IF the push button is pressed THEN GOTO countdown from 9-0 in a continual loop, IF pressed again count down from 5-0 then stop.

    This project covers a lot of the ground we've been over in the last week or two and would give me some much needed practical practice.

    Another question: Is this program statement viable / do-able to provide input words into the decoder driver?

    i VAR WORD
    Main:
    For i = 0 to 3 etc
    LOOKUP i, [0, 1,2,3], GPIO
    NEXT i

    Sorry but the code tags didn't work tonight.

    This would output from the PIC (I hope):

    0000 making the driver display '0'
    0001 " " '1'
    0010 " " '2'
    0011 " " '3'
    1000 " " '4'

    Also from the output side of the PIC ('words') to the input side of the display driver, I'd like to bleed off a little current to the base of four transistors with LED's in the collector leg to visually see the binary count, just for fun.

    So what do we think then guys? Have I learned my lessons well, or am I heading for the books...!

    David

Members who have read this thread : 0

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