Q: using MCLR for Input on 12F683


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    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 johnnylynx View Post
    Thanks LinkMTech and Mackrackit:

    Both worked. FYI, I fly RC planes and have recently gained interest in the PIC stuff, mostly with the 12F683 due to its size. I'm learning this stuff...slowly (but wow, has it got potential!).

    I have a couple more questions hopefully you can help me with.

    1. having some issues simply running LED's on ports other than gpio.0 and 1. I'm not sure if I need to assign them, change them??? When trying, I see they have a faint glow???

    2. When using GPIO.4 and an input to store a pulsin value, the program works, but if I use GPIO.3 it doesn't. I can't figure that one out.

    Thanks again gents.

    John.
    Can you post your code?
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Whoops, sorry about that!

    here's the code:


    oSCCON = %01100000 ' Ocs set to 4 MHz
    TRISIO = %00000000 ' Set all ports to outputs, in this example
    CMCON0 = 7 ' Analog comparators off
    ANSEL = 0 ' Analog select set to digital, pg 69 data
    ADCON0 = 0 ' A/D turned OFF, pg 68 of data
    input gpio.4

    inpulse VAR Word
    memory var word
    low gpio.4
    low gpio.3


    start:


    SEROUT 0, 2, [12]
    start2:
    PULSIN 1, 1, inpulse

    if inpulse<50 then
    read 5, memory
    serout 0,2,[12,17, "Activating",13,"Failsafe :", #memory*10]
    goto start2
    else
    endif

    if gpio.4=1 then
    write 5, inpulse
    serout 0,2,[12,17,"Failsafe",13,"Stored :", #inpulse*10]
    high gpio.3
    low gpio.4
    else
    low gpio.3
    endif

    SEROUT 0, 2, [17,22,#inpulse*10]
    PAUSE 20


    GOTO start

    END

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


    Did you find this post helpful? Yes | No

    Default

    OSCCON = %01100000 ' Ocs set to 4 MHz
    TRISIO = %00000000 ' Set all ports to outputs, in this example
    CMCON0 = 7 ' Analog comparators off
    ANSEL = 0 ' Analog select set to digital, pg 69 data
    ADCON0 = 0 ' A/D turned OFF, pg 68 of data
    input gpio.4 '<font color=red> make input</font color>

    inpulse VAR Word
    memory var word
    low gpio.4 <font color = red> ' Now you make it an output</font color>
    low gpio.3


    start:


    SEROUT 0, 2, [12]
    start2:
    PULSIN 1, 1, inpulse

    if inpulse<50 then
    read 5, memory
    serout 0,2,[12,17, "Activating",13,"Failsafe :", #memory*10]
    goto start2
    else
    endif

    if gpio.4=1 then '<font color=red> still an output, are you wanting an input?</font color>
    write 5, inpulse
    serout 0,2,[12,17,"Failsafe",13,"Stored :", #inpulse*10]
    high gpio.3
    low gpio.4 '<font color=red> is and should be an output</font color>
    else
    low gpio.3
    endif

    SEROUT 0, 2, [17,22,#inpulse*10]
    PAUSE 20


    GOTO start

    END
    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.

  4. #4
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe,

    I didn't catch that, I'll make changes and see if that fixes the input problem.

    I still have the output issue though with GPIO.3, it doesn't want to run the LED.

    Any thoughts?

    John.

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


    Did you find this post helpful? Yes | No

    Default

    Not sure but I think that pin is input only.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I dunno John, I never use the High / Low convention, preferring to specify TRISIO AND GPIO instead because as I understand it , High/Low reads modify's and writes the whole port ( all the I/Os ) when you do.
    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.

  7. #7
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks guys,

    I think I've got it working OK now...but by copy of the picbasic compiler (with microcode studio) only limits me to 31 code lines

    As much as I like Microcode Studio...is there something out there a guy can use that is much cheaper than picbasic pro AND is downloadable from the NET?

    John.

Similar Threads

  1. How to MCLR by code for 16F877
    By fbestepe in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th November 2014, 00:51
  2. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 17:38
  3. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 06:16
  4. What does this MCLR instruction mean?
    By bartman in forum General
    Replies: 16
    Last Post: - 30th November 2004, 00:32
  5. I/O pin and MCLR
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 1
    Last Post: - 15th July 2004, 10:52

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