12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Dave, use <code> tags and format your code - makes it easier to read.
    Code:
    ANSEL  = %00000000 'disable analog select so ports work as digital i/o
    CMCON0 = %00000111 'Disable analog comparators
    TRISIO = %11001111 'Set GPIO.4&5 to input
    GPIO   = %00000000 ' set all outputs low
    
    i VAR BYTE
    
    START
    Main:
    pause 500          'pause 500 mili-secs
    For i = 1 to 3     ' loop count variable (value i) also number of times to loop.
      LOOKUP i, [ 223, 223, 223] ,GPIO      '223 = %11011111 D0 switches on (GPIO.4)
      Pause 500        'pause 500 mili-secs
      LOW GPIO.4       ' DO switches off
    Next i             ' loop again. ONE is added to count i and prog jumps to FOR

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


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    Two things.... First as you figured out and as Alain also pointed out you will need an END after the loop or the PIC will wonder off to never never land eventually starting over (I think). Second, you need another PAUSE in there or you will not see the LED blink. It will get turned on then 500ms later it will get turned off and then on again almost instantly as the loop goes back to the beginning. I guess that's what you were trying with the PAUSE right after Main but remeber that the loop starts over at the FOR statement.
    Code:
    Main:
    pause 500          'pause 500 mili-secs
    For i = 1 to 3     ' loop count variable (value i) also number of times to loop.
      LOOKUP i, [ 223, 223, 223] ,GPIO      '223 = %11011111 D0 switches on (GPIO.4)
      Pause 500        'pause 500 mili-secs
      LOW GPIO.4       ' DO switches off
      Pause 500
    Next i
    END

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


    Did you find this post helpful? Yes | No

    Default

    Henrik you are a star.....!

    So I was pretty close then? I guess we wouldn't want to be flying in an aeroplane with any PIC'S in it I'd programmed just yet though...

    Right, I'm off for some for-next-loop practice.

    Cheers: Dave

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    Testing 1.2.3.
    So that's a code tag then, I really didn't know that...doh.

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


    Did you find this post helpful? Yes | No

    Default

    Evening everyone.

    I've been doing a lot of reading of late some beneficial some confusing.

    I've decided to try and make a 12F683 turn an LED on when a button is momentarily pressed, then expand this further. I can see lots of possibilities in being able to make outputs do different things on receipt of an input/s.

    Is something like this on the right lines?

    Code:
    IF GPIO.x = HIGH 'Button is pressed.
    
    THEN OUTPUT GPIO.x HIGH 'Turns LED on
    I've put the driving a seven segment display using a 16F684 and part of two ports to on hold just for the minute.

    David

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


    Did you find this post helpful? Yes | No

    Default

    Almost...
    Take a look at this. From the manual...
    http://www.melabs.com/resources/pbpmanual/5_32-5_35.htm
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    Evening everyone.

    I've been doing a lot of reading of late some beneficial some confusing.

    I've decided to try and make a 12F683 turn an LED on when a button is momentarily pressed, then expand this further. I can see lots of possibilities in being able to make outputs do different things on receipt of an input/s.

    Is something like this on the right lines?

    Code:
    IF GPIO.x = HIGH 'Button is pressed.
    
    THEN OUTPUT GPIO.x HIGH 'Turns LED on
    I've put the driving a seven segment display using a 16F684 and part of two ports to on hold just for the minute.

    David
    Hi David,
    I think I smell what you are cooking, you want to send power to a port and then have it stay powered after you release the switch. I Used to install gun lock timers that were wired that way.
    Try This UNTESTED CODE
    Code:
    GPIO  = %00000000 ' set all outputs as low
    TrisIo = %00000001 'make all outputs except GPIO.0
    main:
    If GPIO.0 then unlock
    goto main
    unlock:
    Trisio.0 = 0 'changes to output
    GPIO.0 = 1 'sets port latch to high logic
    pause 30000 ' wait 30seconds
    GPIO.0 = 0 :TRISIO.0 = 1 ' Turn it off
    goto main
    
    end
    Keep in mind there is no setup code appropriate to your PIC
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,everyone. Sorry for the slow reply, it's been one of those days today.
    Before I forget I loved the line: "I think I smell what you are cooking" It's had me smiling all day.

    Joe, the program you wrote. I was happy with all of it except line four.I see you've made GPIO.0 an input
    but the 'THEN' label hasn't been given a HIGH or LOW statement for the pin

    Code:
    If GPIO.0 then unlock
    To my mind (please be gentle with me I'm really green at this) it should be something like:

    Code:
    IF GPIO.0 = HIGH THEN  UNLOCK ' GPIO.O goes HIGH (button pressed) jump to
    label UNLOCK.
    
    
    ELSE  GOTO MAIN ' button not pressed do the loop again 
    (not sure if I needed the GOTO here).
    
    Or maybe:
    
    IF GPIO.O = LOW THEN MAIN ' button not pressed,  do the loop again
    Am I on the right lines here?

    * Silly but important question here*: I'm confusing myself, can an INPUT be either HIGH or LOW?
    I know an OUTPUT can be.

    So your program is maybe a timed latching relay circuit or locking solenoid?

    As for my program, I was thinking more along the lines that if GPIO.X goes high (a button is pressed +5v on that input pin) that would make an output on GPIO.Y go high. In other words the pressing of a button makes the program jump to some specified section of code making an output.

    Then moving this idea on, if the button was pressed twice (within a certain time period say) you could 'jump' to another section of code and make a different output..

    I hope you're all having a pleasant evening,

    David
    Last edited by LEDave; - 27th February 2010 at 23:16.

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