12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2013
    Posts
    1,109

    Default 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    Hello.
    I have PIC12F1840 configured to output PWM signal on P1B port (PORTA.4), according to APFCON register.

    However, HPWM 1, 127, 20000 (as example)
    outputs PWM signal on PORTA.2 pin.

    I tried to configure APFCON register accordingly, but no luck.
    I tried HPWM 2, HPWM 3 etc - no difference.
    Hardware-wise everything is ok, since high/low, PWM PORTA.4 all work fine.

    Here's my config.
    What can be the reason?

    Code:
    ;----[12F1840 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "12F1840"
      #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _FOSC_INTOSC           ; INTOSC oscillator: I/O function on CLKIN pin
    cfg1&= _WDTE_OFF              ; WDT disabled
    cfg1&= _PWRTE_OFF             ; PWRT disabled
    cfg1&= _MCLRE_OFF             ; MCLR/VPP pin function is digital input
    cfg1&= _CP_OFF                ; Program memory code protection is disabled
    cfg1&= _CPD_OFF               ; Data memory code protection is disabled
    cfg1&= _BOREN_ON              ; Brown-out Reset enabled
    cfg1&= _CLKOUTEN_OFF          ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
    cfg1&= _IESO_ON               ; Internal/External Switchover mode is enabled
    cfg1&= _FCMEN_ON              ; Fail-Safe Clock Monitor is enabled
      __CONFIG _CONFIG1, cfg1
    
    
    cfg2 = _WRT_OFF               ; Write protection off
    cfg2&= _PLLEN_OFF             ; 4x PLL disabled
    cfg2&= _STVREN_ON             ; Stack Overflow or Underflow will cause a Reset
    cfg2&= _BORV_19               ; Brown-out Reset Voltage (Vbor), low trip point selected.
    cfg2&= _LVP_OFF               ; High-voltage on MCLR/VPP must be used for programming
      __CONFIG _CONFIG2, cfg2
    
    
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    'include "modedefs.bas"
    
    
    
    
    OSCCON = %11110000  'SET INTOSC TO 32MHZ
    TRISA=%00000000 'set PORt as input
    ANSELA=%0000000 'set PORTA.4 as analog
    ADCON0=%0000000  'ENABLE AND CONFIGURE ADC
    ADCON1=%11000011   'JUSTIFY
    FVRCON=%11011110 'VREF ENABLE & set at 2.048v
    WPUA=%00000000 'pull up disable
    APFCON=%00000010 'SET PWM TO LATA.5
    'CM1CON0=%00000000   'DISABLE COMPARATORS
    
    
    DEFINE OSC 32
    DEFINE ADC_BITS 10
    DEFINE ADC_SAMPLEUS 50
    DEFINE ADC_CLOCK 3
    
    HPWM 1,127,20000
    STOP

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,064


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    I read somewhere that HPWM uses CCP pins (PBP manual?).
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Feb 2013
    Posts
    1,109


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    Yes it does, but when chip has multiple PWM output pins, usually HPWM 2, HPWM 3, etc, output on the corresponding pin.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,556


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    you need to set the steering mode to drive p1b
    Warning I'm not a teacher

  5. #5
    Join Date
    Feb 2013
    Posts
    1,109


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    Thanks, will try it a bit later!

  6. #6
    Join Date
    Feb 2013
    Posts
    1,109


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 - HPWM outputs PWM on CCP pin instead of P1B pin.

    This fixed it, thanks again!

    APFCON=%00000010
    PSTR1CON=%00010010

Similar Threads

  1. PBP Support for 12F1840 8-Pin Device?
    By springtank in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 10th November 2012, 09:32
  2. Replies: 5
    Last Post: - 24th July 2010, 10:34
  3. 8 pin DIP w/6 outputs ?
    By Sam in forum General
    Replies: 12
    Last Post: - 14th September 2009, 21:15
  4. Pin outputs to an array
    By Firegod in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th March 2007, 18:35
  5. Multiplexing PWM pin with other outputs
    By bcd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th September 2006, 12:24

Members who have read this thread : 10

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