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
Bookmarks