Beginner in need of help !!


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Hi, please can someone tell me how I disable MCLR on gp3 (my pic is 12f683). Ive been researching for the past 2 hours & I have got no closer to disabling it, I just want GP3 as a normal input pin, not this MCLR crap!

    If anyone knows could you please help?

    Rob

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


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Hi,
    MCLR is disabled by clearing the correct "fuse" in the CONFIG word. With PBP3 you set the CONFIG word(s) with the #CONFIG/#ENDCONFIG compiler directives (more on that in the manual). Your PBP3 installation folder has a subfolder named DEVICE_REFERENCES in which you'll find a file for each and every device the compiler supports. The file contains information about the various CONFIG options and also what defaults PBP uses if you don't include any in your code.

    For a 12F683 the defaults are:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    If you want to disable MCLR and keep everything else then copy/paste this into your program:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    /Henrik.

  3. #3
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    MCLR is disabled by clearing the correct "fuse" in the CONFIG word. With PBP3 you set the CONFIG word(s) with the #CONFIG/#ENDCONFIG compiler directives (more on that in the manual). Your PBP3 installation folder has a subfolder named DEVICE_REFERENCES in which you'll find a file for each and every device the compiler supports. The file contains information about the various CONFIG options and also what defaults PBP uses if you don't include any in your code.

    For a 12F683 the defaults are:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    If you want to disable MCLR and keep everything else then copy/paste this into your program:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    /Henrik.
    Your a life saver mate. I knew I had to write to the config but I just could not find out which way to do it, I was nearly there I was putting @config instead though!

    Thanks again,
    Rob

  4. #4
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    MCLR is disabled by clearing the correct "fuse" in the CONFIG word. With PBP3 you set the CONFIG word(s) with the #CONFIG/#ENDCONFIG compiler directives (more on that in the manual). Your PBP3 installation folder has a subfolder named DEVICE_REFERENCES in which you'll find a file for each and every device the compiler supports. The file contains information about the various CONFIG options and also what defaults PBP uses if you don't include any in your code.

    For a 12F683 the defaults are:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    If you want to disable MCLR and keep everything else then copy/paste this into your program:
    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    /Henrik.
    Hi Henrik, I am going to start my first project which will hopefully teach me new things along the way. I have question for you before I start though, I am hoping you can give a short answer to this.

    Basically I want different modes (say 10) which are each cycled through via a tap of a tactile button (so mode 1, tap button, mode 2, tap, mode 3, etc) & each mode has its own led flashing at a different speed.

    My question is, which way is the best to do this? With interrupts or something else? I would also like the chip to watch for other button presses as well not just this one sequence of modes, so its not going to be just a simple sequnce of button tap to next mode etc.

    So I need a way of watching for multiple input changes all the time, I am expecting interrupts to be the answer after reading about, but just want to be sure

    Hope you can help,
    Rob
    Last edited by robbo78; - 21st January 2015 at 09:48.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Hi Rob,
    There are several ways - as is the case most of the time.
    Interrupts are probably the way to go but there may be other ways.

    Do you have a particular chip in mind, is it still the 12F683? I think not since you mention 10 modes, each with its own LED.....
    How many switches do you need to monitor?

    /Henrik.

  6. #6
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Hi Henrik, I will still be using the pic12f683. This is just a starter project which I am hoping to take to something bigger, but I will be flashing 1 led, the 10 modes are all outputting to the one led. I would like to sense 2 inputs, 1 tactile button & 1 using adc to mintor coltage change.

    Thanks,
    Rob

  7. #7
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Angry Re: Beginner in need of help !!

    Okay I have had a go & failed What am I doing wrong?

    Code:
    'PIC12f683
    
    #CONFIG 
       __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    
    DEFINE OSC 4 '4mhz ocsillator
    ANSEL = %00000010 'pin 6 analog
    CMCON0 = %00000100 'comparator mode
    VRCON = %00001000 'voltage reference
    TRISIO = %00000010 'pin 6 input
    
    POTEN VAR CMCON0.1 'pot pin 6
    LED VAR GPIO.2 'led pin 5
    
    PAUSE 20
    
    main:
    IF CMCON0.1 = 1 THEN
    HIGH LED
    ELSE
    LOW LED
    ENDIF
    GOTO main

  8. #8
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Rob,

    Glad to see your working through the design and issues.
    You are very close.

    Here are a couple of things you need to correct.
    1. VRCON: Look at the register description in "Register 8-3" on page 53 of the datasheet.
    In your program you are setting VRCON like this: VRCON = %00001000 'voltage reference
    There are more bits in the register that you need to take into account.
    A. You have bit7=0 which does this "0 = CVREF circuit powered down, no IDD drain and CVREF = VSS". This turns OFF the internal reference voltage.
    You need to change this to "1", 1 = CVREF circuit powered on, to turn on the internal reference voltage circuit.
    B. You have bit5 = 0 which does this "VRR: CVREF Range Selection bit 0=High Range"
    This changes your CVref equation and result to this: "VRR = 0, CVREF = (VDD/4) + (VR3:VR0 X VDD/32)", which when you plug in your values you get this
    for your reference voltage. (3.3/4) + (8/32) = (0.825) + (0.25) = 1.075 Vdc. Now this may be what you were actually trying to do, if so then your are good.

    2. In your main loop you are attempting to test the output of the Comparator like this: "IF CMCON0.1 = 1 THEN"...
    Look at the CMCON0 register description in "Register 8-1" on page 47 of the datasheet and compare that with the "CMCON0.1 = 1" above.
    You are testing bit1 of the CMCON0 register, that is what the ".1" does. xxxx.1 says I want to look at bit1 of xxxx.
    Is this the bit you need to check for the Comparator Output? If you're not sure have a look at "FIGURE 8-3" on page 49 and look at the figure for the
    CM Mode you are using "100". That diagram indicates what the Comparator Output is by name.

    Check and correct this.

    3. Lastly, and somewhat obscure in the DS, you need to determine how you want the Comparator to test and output.
    As I understand you want to check the input pin voltage against your "1.075 Vdc" reference you are setting up internally and have the following outcomes:
    If the input is "Lower than 1.075 Vdc" you want the LED to be OFF and you want the LED to be "ON when the input is Higher than 1.075 Vdc".

    To get these results you need to take a look at a couple of items in the datasheet.
    A. Look at CMCON0, "Register 8-1" on page 47, and review the information for bit6 and bit4.
    Also look at "TABLE 8-1" on page 48.
    Between these two, you should be able to piece together how you need to configure the operation to get your desired "Output" of the Comparator.

    You are getting close, hopefully these additional points will get you further on your way.

    Regards,
    Regards,
    TABSoft

  9. #9
    Join Date
    Jan 2015
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Hi Tabsoft, thanks a lot for your help I appreciate it. I will go back through everything you have stated & set it up right this time. I did think there were other bits to change but didnt want to mess as I didnt know what I was doing, but ai should now with your info.

    Thanks again, I will let you know how it goes.
    Rob

  10. #10
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Beginner in need of help !!

    Rob,

    One correction in my earlier post.

    The CVref calculation for High Range is CVREF = (VDD/4) + (VR3:VR0 X VDD/32).
    Using your input values of VDD=3.3 and VR3:VR0=8, the calculation will come out like this.
    (3.3/4) + (8 x (3.3/32) = (0.825) + (8 x 0.103125) = (0.825) + (0.825) = 1.65 Vdc

    If you use Low Range then here is the info:
    CVREF = (VR3:VR0/24) x VDD = (8/24) x 3.3 = 0.333 x 3.3 = 1.1 Vdc

    Regards,
    Regards,
    TABSoft

Similar Threads

  1. Beginner help!
    By Recognize in forum General
    Replies: 14
    Last Post: - 26th April 2012, 15:55
  2. pic24 beginner
    By robertpeach in forum General
    Replies: 23
    Last Post: - 13th August 2009, 12:57
  3. need help! to beginner
    By emilhs in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 6th May 2009, 19:44
  4. Beginner at PB
    By alphahr in forum Off Topic
    Replies: 1
    Last Post: - 21st April 2008, 18:43
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 6th May 2005, 00:29

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