PWM instruction not working as I expect


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    I won't ask howto but where to look for the answer

    I'm trying to use gpio.3 as an input, but I dont know how to set it as such.

    Setting trisio=%00001000 does not help me

    Thanks in advance

    Quote Originally Posted by Bruce
    Hi Pablo,

    Look in the data sheet under Comparator Module. Look at the "default" POR (power on reset) value in CMCON0.

    Now look at the drawing in FIGURE 8-3: COMPARATOR I/O OPERATING MODES.

    Place CMCON0 = X in the initialization section of your code.

    Replace X with the value shown in this section that will turn "Comparator Off".

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Pablo,

    PBP has default config fuse settings in device specific header files. Look in your PBP directory for a file named 12F683.INC. Open this file.

    You'll see the PBP default config fuse settings for this target PIC. It looks somthing like this;

    This is used only if you're using the default PM asembler that ships with PBP.

    device pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off

    And this one is used when you're using the Microchip MPASM assembler.

    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

    Notice how the default settings for /MCLR (GPIO.3) all have the reset function enabled (mclr_on, _MCLRE_ON)?

    You can over-ride these default config fuse settings, and make GPIO.3 available as an input by editing the file, and changing it to mclr_off or _MCLRE_OFF, save the file, and re-compile.

    Or simply add this line to the beginning of your code (if using the PM asembler);

    @ device pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off

    Now you just need to make the pin an input by setting the appropriate TRIS bit.

    Melanie posted a nice tutorial on config settings here:
    http://www.picbasic.co.uk/forum/showthread.php?t=543 so I won't elaborate.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Thanks again Bruce, just added that line, and now I can use this extra pin !!

    I trully appreciate your answers.


    Pablo

Similar Threads

  1. HW PWM not working
    By comwarrior in forum General
    Replies: 5
    Last Post: - 31st July 2009, 17:16
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM: Vernacular/Function (Newbee)
    By TerryN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd July 2008, 16:58
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00:26

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