PWM on PIC16F88


Closed Thread
Results 1 to 37 of 37

Thread: PWM on PIC16F88

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If you followed the instructions in this thread...

    http://www.picbasic.co.uk/forum/showthread.php?t=543

    You would have discovered you needed CCPMX_OFF somewhere in your @ DEVICE statement.

    If using MPASM you would have needed _CCP1_RB3 in your config definitions.

    The clue is in the fact that this is a CONFIGURATION WORD (CONFIG FUSE) setting (see PICs Datasheet) therefore you need to make those changes in your CONFIG Definitions which are burnt into the chip at Program Time.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie but it still doesn't work. My programmer gives me the option to change CCP1 ports on the F818 but not the F88. I spent hours changing the code but the HPWM command always comes out on RB0.

    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON, CCPMX_OFF
    DEFINE CCP1_BIT 3 ' ***IT'S STILL ON RB0

    It compiles without errors but RB0 still outputs the PWM. HELP!! The PC Board pattern will allow the use of RB3 perfectly. If I HAVE to use RB0, I have to cut traces & solder jumper wires. Thank you.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If your programmer does not give you full control of your Configuration Word for the 16F88, you must get back to the vendor that produced your programmer software for an update, or buy a new programmer, or call a friend who has the facility on theirs, or buy a few crates of beer (most problems dissappear after the first crate)...

  4. #4


    Did you find this post helpful? Yes | No

    Default

    I guess I have to settle for PWM on RB0. No matter what I do, I can't enable RB3. Now I have 2 new things on my "to do" list. 1 - update my programmer, 2 - buy a case of Budweiser.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well the Beer option may help or not... What about if you use the MPASM assembler instead of PM?
    Look at the 16F88.INC file..
    Quote Originally Posted by 16F88.INC
    ;================================================= =========================
    ;
    ; Configuration Bits
    ;
    ;================================================= =========================

    _CONFIG1 EQU H'2007'
    _CONFIG2 EQU H'2008'

    ;Configuration Byte 1 Options
    _CP_ALL EQU H'1FFF'
    _CP_OFF EQU H'3FFF'
    _CCP1_RB0 EQU H'3FFF'
    _CCP1_RB3 EQU H'2FFF'
    _DEBUG_OFF EQU H'3FFF'
    _DEBUG_ON EQU H'37FF'
    _WRT_PROTECT_OFF EQU H'3FFF' ;No program memory write protection
    _WRT_PROTECT_256 EQU H'3DFF' ;First 256 program memory protected
    _WRT_PROTECT_2048 EQU H'3BFF' ;First 2048 program memory protected
    _WRT_PROTECT_ALL EQU H'39FF' ;All of program memory protected
    _CPD_ON EQU H'3EFF'
    _CPD_OFF EQU H'3FFF'
    _LVP_ON EQU H'3FFF'
    _LVP_OFF EQU H'3F7F'
    _BODEN_ON EQU H'3FFF'
    _BODEN_OFF EQU H'3FBF'
    _MCLR_ON EQU H'3FFF'
    _MCLR_OFF EQU H'3FDF'
    _PWRTE_OFF EQU H'3FFF'
    _PWRTE_ON EQU H'3FF7'
    _WDT_ON EQU H'3FFF'
    _WDT_OFF EQU H'3FFB'
    _EXTRC_CLKOUT EQU H'3FFF'
    _EXTRC_IO EQU H'3FFE'
    _INTRC_CLKOUT EQU H'3FFD'
    _INTRC_IO EQU H'3FFC'
    _EXTCLK EQU H'3FEF'
    _HS_OSC EQU H'3FEE'
    _XT_OSC EQU H'3FED'
    _LP_OSC EQU H'3FEC'

    ;Configuration Byte 2 Options
    _IESO_ON EQU H'3FFF'
    _IESO_OFF EQU H'3FFD'
    _FCMEN_ON EQU H'3FFF'
    _FCMEN_OFF EQU H'3FFE'
    so you must use the following line... written AS IS
    Code:
    @ __CONFIG _CONFIG1, _CCP1_RB3 & _DEBUG_OFF & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_ON & _INTRC_IO
    NOW, what about something like
    Code:
    @ __CONFIG _CONFIG1, _CCP1_RB3 & _DEBUG_OFF & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_ON & _INTRC_IO
    OSCCON=$60 ' use internal 4MHZ osc
    PAUSE 100 ' start-up delay
    TRISB=0
    DEFINE CCP1_REG PORTB 
    DEFINE CCP1_BIT 3 
    HPWM 1,1000,128
    HERE: GOTO HERE
    Maybe you'll have the same results... maybe not. Keep us inform.
    Last edited by mister_e; - 8th January 2006 at 18:57.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    DARGH! Maybe not, just read the datasheet and the PM >INC file CCPMX should set ON.
    Quote Originally Posted by 16F88.INC
    CCPMX_ON equ 2FFF0000h ; X0 XXXX XXXX XXXX
    CCPMX_OFF equ 2FFF1000h ; X1 XXXX XXXX XXXX
    in datasheet... you'll find
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=709&stc=1&d=1136747056 ">

    NOW, what about
    Code:
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON, CCPMX_ON
    OSCCON=$60 ' use internal 4MHZ osc
    PAUSE 100 ' start-up delay
    TRISB=0
    DEFINE CCP1_REG PORTB 
    DEFINE CCP1_BIT 3 
    HPWM 1,1000,128
    HERE: GOTO HERE
    Attached Images Attached Images  
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve but I think Melanie is right - time for a lot of beer. Followed your code exactly and the PWM still comes out on RB0. Do you have any other ideas I can try when I get sober?

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  4. Replies: 8
    Last Post: - 7th December 2006, 15:42
  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