SOLVED - IOC works on B0 but not B5


+ Reply to Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042

    Default SOLVED - IOC works on B0 but not B5

    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...?
    Last edited by Demon; - 16th September 2024 at 21:48.
    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!

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,546


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    you need to read and adhere to the PBP3_PPS_notes.txt file in your pbp3 directory


    THIS FILE HAS BEEN UPDATED FOR PBP 3.1.1


    Devices with full Peripheral Pin Select (PPS) may be manipulated with the
    DEFINEs listed below. Default values shown may be subject to change due to
    Microchip pre-defined values. If in doubt, use the DEFINES to override defaults.




    --------------------------------------------------------------------------------


    Default output pins if no DEFINE is used:


    Pins: 8 14/16 20 28/40/48 64
    CCP1 RA2 RC5 RC5 RC2 RC2
    CCP2 RA5 RC3 RC3 RC1 RC1
    CCP3 RA2 RA2 RB5 RC3
    CCP4 RC1 RA4 RB0 RG3


    RX1 RA1 RC5 RB5 RC7 RC7
    TX1 RA0 RC4 RB7 RC6 RC6
    RX2 RC1 RC1 RB5* RG2
    TX2 RC2 RC2 RB4* RG1


    * RX2/TX2 defaults changed for some devices in PBP 3.1.1 to avoid ICSP lockout.


    Note that on some devices, any pin that is assigned to a CCP channel
    may not function as normal I/O. If a pin's CCP default inhibits a
    desired function, you can cancel the default as described below.


    --------------------------------------------------------------------------------
    HPWM


    Use the following PBP DEFINE statements to specify the output pins for HPWM.
    Check the Microchip datasheet (Peripheral Pin Select PPS) for the pins allowed
    on each CCP channel. The PPS peripheral will automatically be configured
    for the specified output pin upon execution of HPWM. When used on devices
    without PPS, these defines will only control the Data Direction SFRs (TRIS).


    These defines set PPS SFRs only once at program initialization. You may
    change the PWM output pin at any point in your program code by modifying
    the PPS SFRs. The HPWM command may be used without these DEFINEs if you
    manually configure the PPS and TRIS SFRs.


    As noted below, you may use DEFINE CCPx_REG 0 to inhibit PPS inititalization
    and automatic TRIS settings for any channel. You should do this if you plan
    to relocate pins with PPS settings at run-time to avoid erroneous TRIS settings.




    DEFINE CCP1_REG PORTC 'Channel-1 port
    DEFINE CCP1_BIT 2 'Channel-1 bit
    DEFINE CCP2_REG PORTC 'Channel-2 port
    DEFINE CCP2_BIT 1 'Channel-2 bit
    DEFINE CCP3_REG PORTC 'Channel-3 port
    DEFINE CCP3_BIT 3 'Channel-3 bit
    DEFINE CCP4_REG PORTG 'Channel-4 port
    DEFINE CCP4_BIT 3 'Channel-4 bit
    DEFINE CCP5_REG PORTG 'Channel-5 port
    DEFINE CCP5_BIT 4 'Channel-5 bit
    DEFINE CCP6_REG PORTE 'Channel-6 port
    DEFINE CCP6_BIT 6 'Channel-6 bit
    DEFINE CCP7_REG PORTE 'Channel-7 port
    DEFINE CCP7_BIT 7 'Channel-7 bit


    DEFAULT CCP PINS SET FOR UNUSED HPWM CHANNELS! If CCP_REG DEFINEs are set
    for unused channels, either explicitly or by default, the ports/pins specified
    as CCP/PWM outputs may not function as normal I/O until the PPS SRFs are cleared
    in your program code. To remove a default setting, define the CCPx_REG as 0,
    for example:


    DEFINE CCP1_REG PORTC 'Channel-1 port
    DEFINE CCP1_BIT 2 'Channel-1 bit
    DEFINE CCP2_REG 0 'Channel-2 UNUSED
    DEFINE CCP2_BIT 0 'Channel-2 bit
    DEFINE CCP3_REG 0 'Channel-3 UNUSED
    DEFINE CCP3_BIT 0 'Channel-3 bit
    DEFINE CCP4_REG 0 'Channel-4 UNUSED
    DEFINE CCP4_BIT 0 'Channel-4 bit


    Oooops, added edit to your post by mistake.... (- Demon)
    Last edited by Demon; - 13th September 2024 at 04:20.
    Warning I'm not a teacher

  3. #3
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    169


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    I don't understand how you seem to have disabled the PPS for pins B0 and B5 without allocating something to them. Don't they need something allocated to them whether it's a port access or peripheral whatever if you plan to use the pins?

    Apologies, I'm still learning this stuff,

    Troy

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by richard View Post
    you need to read and adhere to the PBP3_PPS_notes.txt file in your pbp3 directory
    Aren't those DEFINES the exact same thing as:

    Code:
    PinD2   CON %011010                     ' Datasheet table 13-2
    CCP3PPS = PinD2                         ' CCP3 Peripheral input selection
    
    PeripheralCCP3  CON %001011             ' Datasheet table 13-3
    RD2PPS = PeripheralCCP3                 ' Pin D2 output source selection
    
    RB5PPS = 0                              ' Disable CCP3 on pin B5 (moved to D2)
    Or is there an extra step going on in the background?
    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!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by rocket_troy View Post
    I don't understand how you seem to have disabled the PPS for pins B0 and B5 without allocating something to them. Don't they need something allocated to them whether it's a port access or peripheral whatever if you plan to use the pins?

    Apologies, I'm still learning this stuff,

    Troy

    Yeah, so am I.

    I looked for a way to move "treat this like a GP pin" via PPS settings, but I don't see anything like that.

    Unless you just can't recycle CCP pins, unless you move another peripheral to it (which is very possible).
    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!

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,546


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    you seem to have disabled the PPS for pins B0 and B5 without allocating something to them
    the power on default state for RxyPPS regs is 0 ie pin is assigned to be gpio
    so
    RB0PPS = 0 assigned to pin RB0 TO be a gpio pin [which it already was ]


    none of this serves any worthwhile purpose if you do the pbp3 HPWM defines correctly


    Code:
    PinD2   CON %011010                     ' Datasheet table 13-2
    PinD3   CON %011011
    CCP3PPS = PinD2                         ' CCP3 Peripheral input selectiowm  in hpm mode the ccp modules have no input function 
    CCP4PPS = PinD3                         ' CCP4 Peripheral input selection
    
    
    PeripheralCCP3  CON %001011             ' Datasheet table 13-3         
    PeripheralCCP4  CON %001100
    RD2PPS = PeripheralCCP3                 ' Pin D2 output source selection  all done with pbp define
    RD3PPS = PeripheralCCP4                 ' Pin D3 output source selection
    
    
    RB0PPS = 0                              ' Disable CCP4 on pin B0 (moved to D3) all done with pbp define
    RB5PPS = 0                              ' Disable CCP3 on pin B5 (moved to D2)
    Warning I'm not a teacher

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,546


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    did i say ioc pin change is a bad way to do keys

    try this and compare results

    Code:
    #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_ON
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    
    DEFINE OSC 32
    define  CCP4_REG     PORTD              ' PWM Pulse out to LCD contrast
    DEFINE  CCP4_BIT     2                  '   2N2907 PNP with 1K on base
    define  CCP3_REG     PORTD              ' PWM Pulse out to LCD backlight
    DEFINE  CCP3_BIT     3                  '   2N2222A NPN with 1K on base
    define  CCP5_REG     0                
    DEFINE  CCP5_BIT     0                  
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    ANSELD = 0
    ANSELE = 0
    WPUC   = % 00100000                          
    WPUB   = % 00110000 
    TRISA  = % 00001111
    TRISB  = % 11111111
    TRISC  = % 11111111
    TRISD  = % 11110011
    
    
    IOCBN  = % 00100000  
    
    
    PushSwitchA      VAR PortC.5      ;sw2
    PushSwitchB      VAR Portb.4       ;sw1
    PushSwitchC      VAR Portb.5
    InterruptLED     VAR Lata.4
    anotherLED       VAR Lata.5
    polLED           VAR Lata.6
    notherLED        VAR Lata.7
    
    
    
    
    ButtonWasPressed VAR WORD[2]
    lc var byte
        Pause 500                                       ' Let PIC stabilize
        InterruptLED = 0
        anotherLED   = 0
        HPWM 3,250,1953                 ' Pulse Contrast
        HPWM 4,150,1953                 ' Pulse Backlight    
    
    
    Mainloop:
        lc=lc+1
        if lc==50 then
             polLED = !polLED 
             lc=0
        endif
        ButtonWasPressed[0] =  (ButtonWasPressed[0]<<1) +  PushSwitcha  
        ButtonWasPressed[1] =  (ButtonWasPressed[1]<<1) +  PushSwitchb 
        if ButtonWasPressed[0] = $f then                    ' Check flag
             anotherLED = !anotherLED
        endif
        if ButtonWasPressed[1] = $f then                    ' Check flag
            notherLED = !notherLED
        endif 
        if IOCBF then
             InterruptLED = !InterruptLED
            IOCBF = 0
        endif
        pause 10
    goto mainloop

    pps , my way works fine even with no capacitor on the switches
    Last edited by richard; - 13th September 2024 at 04:32. Reason: led shuffle
    Warning I'm not a teacher

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    FOUND IT!

    I had set my CCP defines to CCP4 and CCP5 by mistake, I meant it to be to CCP3 and cCP4.

    Code:
    define  CCP3_REG     PORTD              ' PWM Pulse out to LCD contrast
    DEFINE  CCP3_BIT     2                  '   2N2907 PNP with 1K on base
    define  CCP4_REG     PORTD              ' PWM Pulse out to LCD backlight
    DEFINE  CCP4_BIT     3                  '   2N2222A NPN with 1K on base

    The IOC on B0 and B5 now get detected.


    Here's my complete code:

    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  CCP3_REG     PORTD              ' PWM Pulse out to LCD contrast
    DEFINE  CCP3_BIT     2                  '   2N2907 PNP with 1K on base
    define  CCP4_REG     PORTD              ' PWM Pulse out to LCD backlight
    DEFINE  CCP4_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
    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!

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by richard View Post
    ...none of this serves any worthwhile purpose if you do the pbp3 HPWM defines correctly...
    I'm a very fast learner, as long as you explain very slowly a bunch of times and let me fumble around for a few hours/days.


    I commented out all my PPS settings and those Defines were indeed all I needed for it to work.
    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!

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by richard View Post
    did i say ioc pin change is a bad way to do keys

    try this and compare results...


    pps , my way works fine even with no capacitor on the switches

    Richard, I have no doubt your way is leaner, faster and more efficient. I might even figure out what's going on after staring at it for a few hours with my PBP manual beside me.

    But I have to adapt whatever code I come up with for 88 switches and 24 rotary encoders. So far, this way has worked reasonably well, and I understand what's going on.

    I do appreciate the help and suggestions; I might even try it later, or someone else will.
    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!

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Just to confirm, there definitely is something else required than my PPS settings.

    I commented out the 4 DEFINES and used only my PPS settings and it didn't work.

    I activated the 4 DEFINES and commented out all my PPS settings and it worked.
    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!

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,546


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    for what its worth
    porta.4 also fails to operate as a normal gpio i/p when hpm is used
    DEFINE CCP5_REG 0
    DEFINE CCP5_BIT 0

    is needed to restore operation


    edit, i had mixed up cause and effect i had sw on c5 and led on a4 i assumed led failure to operate as intended was due to sw not working
    but sw was fine led pin not so


    moral to story
    if you use hpm it will mangle all the default pins for normal use unless you take action
    Last edited by richard; - 13th September 2024 at 06:22.
    Warning I'm not a teacher

  13. #13
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    169


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by Demon View Post
    Yeah, so am I.

    I looked for a way to move "treat this like a GP pin" via PPS settings, but I don't see anything like that.

    Unless you just can't recycle CCP pins, unless you move another peripheral to it (which is very possible).
    I was thinking outputs not inputs - [slapping forehead] my bad

    Troy

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by richard View Post
    ...

    Code:
    PinD2   CON %011010                     ' Datasheet table 13-2
    PinD3   CON %011011
    CCP3PPS = PinD2                         ' CCP3 Peripheral input selectiowm  in hpm mode the ccp modules have no input function 
    CCP4PPS = PinD3                         ' CCP4 Peripheral input selection
    
    
    PeripheralCCP3  CON %001011             ' Datasheet table 13-3         
    PeripheralCCP4  CON %001100
    RD2PPS = PeripheralCCP3                 ' Pin D2 output source selection  all done with pbp define
    RD3PPS = PeripheralCCP4                 ' Pin D3 output source selection
    
    
    RB0PPS = 0                              ' Disable CCP4 on pin B0 (moved to D3) all done with pbp define
    RB5PPS = 0                              ' Disable CCP3 on pin B5 (moved to D2)
    in hpm mode the ccp modules have no input function
    I realize that now. I had just gone through the datasheet and picked up all the registers I thought related with PPS, then tried setting them up in my I thought would swap the CCP function from pins Bx to Dx.


    EDIT: Apparently I was doing something wrong, or forgetting something altogether.

    The HPWM command may be used without these DEFINEs if you manually configure the PPS and TRIS SFRs.
    from PBP3_PPS_notes.txt in PBP3_1 folder
    Last edited by Demon; - 13th September 2024 at 17:44.
    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!

  15. #15
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by rocket_troy View Post
    I was thinking outputs not inputs - [slapping forehead] my bad

    Troy
    I'm no better; look at the previous post when I was blindly setting inputs when I was using outputs only.
    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!

  16. #16
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,038


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    If MCC can produce all the config code, why not use this tool?

    For some reason I have not found why I am not able to use it on my PC. But I guess Richard can as we discussed that some time ago.

    Ioannis

  17. #17
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by Ioannis View Post
    If MCC can produce all the config code, why not use this tool? ...
    What is MCC, and what tool are you talking about?
    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!

  18. #18
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,580


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    MCC is the tool. MPLAB Code Configurator.
    Select a device, select peripheral(s), select configuration for those peripheral(s) and it outputs configuration code for you (in C syntax).

  19. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,038


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    This tool comes in two flavors. Stand alone and plug-in for MPLABX

    Here it is https://www.microchip.com/en-us/tool...e-configurator

    There are tutorials also in YouTube

    Ioannis

  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,042


    Did you find this post helpful? Yes | No

    Default Re: IOC works on B0 but not B5

    Quote Originally Posted by rocket_troy View Post
    I don't understand how you seem to have disabled the PPS for pins B0 and B5 without allocating something to them. Don't they need something allocated to them whether it's a port access or peripheral whatever if you plan to use the pins?

    Apologies, I'm still learning this stuff,

    Troy
    (bottom of p. 239 of datasheet 16F18877)

    Note: When RxyPPS = 0x00, port pin Rxy output value is controlled by the respective LATxy bit.
    Took me a while to notice this line.
    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!

Similar Threads

  1. Replies: 12
    Last Post: - 7th September 2024, 16:10
  2. Replies: 8
    Last Post: - 30th August 2024, 20:45
  3. Replies: 4
    Last Post: - 22nd March 2023, 12:32
  4. DS3231 works in one config, but does not works with other IC.
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd December 2019, 20:52

Members who have read this thread : 9

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