SOLVED - IOC works on B0 but not B5


+ Reply to Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    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 03:32. Reason: led shuffle
    Warning I'm not a teacher

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


    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!

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


    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!

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


    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 05:22.
    Warning I'm not a teacher

Similar Threads

  1. Replies: 12
    Last Post: - 7th September 2024, 15:10
  2. Replies: 8
    Last Post: - 30th August 2024, 19:45
  3. Replies: 4
    Last Post: - 22nd March 2023, 11: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, 19:52

Members who have read this thread : 11

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