SOLVED - IOC works on B0 but not B5


Results 1 to 20 of 20

Threaded View

  1. #9
    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

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