Solved in post #8: https://www.picbasic.co.uk/forum/sho...142#post156142
I had set my CCP defines to CCP4 and CCP5 by mistake, I meant it to be to CCP3 and cCP4.
============================
PIC 16F18877
I've:
- moved CCP3 from B5 to D2
- moved CCP4 from B0 to D3
- disabled PPS on pins B0 and B5
I can detect a negative edge on B0, but not on B5.
Code:
@ ERRORLEVEL -306 ; turn off crossing page boundary message
'***********************************************************************
' Default in file: PBP3_1\DEVICES\PIC16F18877.PBPINC *
' List in file: PBP3_1\DEVICE_REFERENCE\PIC16F18877.INFO *
' Note: PIC18 devices, the __CONFIG directive has *
' been superceded by the CONFIG directive *
'***********************************************************************
#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
__config _CONFIG5, _CP_OFF & _CPD_OFF
#ENDCONFIG
;--- Defines -------------------------------------------------------------------
DEFINE OSC 32
DEFINE LCD_DREG PORTD ' Set LCD data port
DEFINE LCD_DBIT 4 ' Set starting data bit
DEFINE LCD_RSREG PORTD ' Set LCD register select port
DEFINE LCD_RSBIT 1 ' Set LCD register select bit
DEFINE LCD_EREG PORTD ' Set LCD enable port
DEFINE LCD_EBIT 0 ' Set LCD enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size
DEFINE LCD_LINES 4 ' Set number of lines on LCD
DEFINE LCD_COM1MANDUS 1000 ' Set COM1mand delay time in microseconds
DEFINE LCD_DATAUS 50 ' Set data delay time in microseconds
define CCP4_REG PORTD ' PWM Pulse out to LCD contrast
DEFINE CCP4_BIT 2 ' 2N2907 PNP with 1K on base
define CCP5_REG PORTD ' PWM Pulse out to LCD backlight
DEFINE CCP5_BIT 3 ' 2N2222A NPN with 1K on base
;--- Setup registers -----------------------------------------------------------
'INTCON = %10000000 ' Controlled by DT-INTS
'PIE0 = %00010000
IOCBP = %00000000 ;IOC Interrupt, Positive Edge, low-to-high
IOCBN = %00100001 ;IOC Interrupt, Negative Edge, from high-to-low
'IOCDP = %00000000 ;...not available
'IOCDN = %00000000 ;...not available
'IOCEP = %00000000 ;...not available
'IOCEN = %00000000 ;...not available
WPUB = %00100001
'=======================================================================================
' CCP3 moved from B5 to D2 !
' CCP4 moved from B0 to D3 !
'=======================================================================================
PinD2 CON %011010 ' Datasheet table 13-2
PinD3 CON %011011
CCP3PPS = PinD2 ' CCP3 Peripheral input selection
CCP4PPS = PinD3 ' CCP4 Peripheral input selection
PeripheralCCP3 CON %001011 ' Datasheet table 13-3
PeripheralCCP4 CON %001100
RD2PPS = PeripheralCCP3 ' Pin D2 output source selection
RD3PPS = PeripheralCCP4 ' Pin D3 output source selection
RB0PPS = 0 ' Disable CCP4 on pin B0 (moved to D3)
RB5PPS = 0 ' Disable CCP3 on pin B5 (moved to D2)
ANSELA = %00000000
ANSELB = %00000000
ANSELC = %00000000
ANSELD = %00000000
ANSELE = %00000000
TRISA = %00000000
TRISB = %00100001
TRISC = %00000000
TRISD = %00000000
TRISE = %00000000
Pause 500
HPWM 3,250,1953 ' Pulse Contrast
HPWM 4,150,1953 ' Pulse Backlight
IOCBF = %00000000
LCDOUT $FE, 1 : Pauseus 1
LCDOUT $FE, $80, "COM/NAV ENCODER TEST" : Pauseus 1
PAUSE 500
Mainloop:
if IOCBF.0 = 1 then
LCDOUT $FE, $94, "... Swap B0 ..." : Pauseus 1
IOCBF.0 = 0
endif
if IOCBF.5 = 1 then
LCDOUT $FE, $D4, "... Swap B5 ..." : Pauseus 1
IOCBF.5 = 0
endif
goto mainloop
end
I've gone through the datasheet, but I can't see anything else "special" about pin B5...?
Bookmarks