Sorry mismatch, wrong file part. Change  (, same result both leds ( one 
together wit pulse))

procedure IOC() is
     pragma interrupt
     if INTCON_RBIF then
        MY_data = portB
-- from datasheet page 87: a mismatch condition will continue to set this 
bit. Reading PORTB will end the mismatch condition and allow the bit to be 
cleared
        MY_bit = pin_B4
        led =!led
       INTCON_RBIF = low
    end if

end procedure

Op maandag 26 september 2022 om 10:52:48 UTC+2 schreef hans:

> Hi Vasile,
> have changed my test program in the same environment ( working with Bo). 
> Pulse now to B4.  but now i see both led continues on. So also the puls is 
> not working.
> attached the altered test version.
> regArds
> Hans
>
> Op zondag 25 september 2022 om 20:34:53 UTC+2 schreef vasile:
>
>> Well, from 102-103 it seems it should work on RB4... try the following 
>> pseudocode.
>> Pin B4 must be set as input and toggled by your hardware. 
>>
>> RCON_IPEN = low ; low priority interrupt, 
>> INTCON_GIE = high   ; enable global interrupts 
>> INTCON_PEIE_GIEL = high  ; enable pheripheral interrupts 
>> INTCON_RBIE = high  ; enable interrupts on change on port B4-B7 
>> var byte MY_data = 0
>>
>> procedure IOC() is
>>      pragma interrupt
>>      if INTCON_RBIF then
>>         MY_data = port_B  
>> -- from datasheet page 87: a mismatch condition will continue to set this 
>> bit. Reading PORTB will end the mismatch condition and allow the bit to be 
>> cleared
>>         MY_bit = pin_B4
>>         INTCON_RBIF = low
>>      end if
>> end procedure 
>>
>> forever loop
>> LED = MY_bit
>> end loop
>>
>>      
>>
>>
>>
>> On Sun, Sep 25, 2022 at 7:59 PM hans <[email protected]> wrote:
>>
>>> Hi Vasile,
>>> I've tried to understand page 103, but I shouldn't have. Anyway, an 
>>> adjustment to my PCB and we happily continue. (to bed on time tonight)
>>> Thanks for all your responses
>>> Hans
>>>
>>> Op zondag 25 september 2022 om 10:43:11 UTC+2 schreef vasile:
>>>
>>>> I guess nothing can be done. This pic (if I don't miss anything) has 
>>>> three interrupts on B0, B1 and B2. I don't see any PPS module. BTW I 
>>>> thought seniors are starting at 3am and sleep at midnight...
>>>>
>>>> On Sun 25 Sep 2022, 10:27 AM hans <[email protected] wrote:
>>>>
>>>>> Hi Vasile,
>>>>> I had pull down on the input, set the pin 5,6 and 7 to output etc....
>>>>> At Mid night I have changed the input from B4 to B0 and now it works 
>>>>> perfect. So what to do if i want to use B4 ??
>>>>> regards
>>>>> Hans
>>>>>
>>>>> Op zondag 25 september 2022 om 08:08:08 UTC+2 schreef vasile:
>>>>>
>>>>>> Hi Hans,
>>>>>> This the way INT1 worked for me on PIC18F26J50, I think your PIC is 
>>>>>> more or less the same, however each PIC has its own stupidity, so it 
>>>>>> might 
>>>>>> not work as expected...
>>>>>>
>>>>>> You might want to set the pull-up resistor on your INT pin ( or not, 
>>>>>> as your schematic requires).
>>>>>> If you are not using dedicated INT pin and your PIC micro has the 
>>>>>> stupid PPS relocation, it will be additional headache, so check all of 
>>>>>> these...
>>>>>> good luck!
>>>>>>
>>>>>> -- -------interrupt of change 
>>>>>> IOC-------------------------------------------------------
>>>>>> var bit MY_flag = low
>>>>>> procedure IOC() is
>>>>>>      pragma interrupt
>>>>>>      if INTCON3_INT1IF then
>>>>>>         MY_flag = high
>>>>>>         INTCON3_INT1IF = low
>>>>>>      end if
>>>>>> end procedure
>>>>>>
>>>>>> RCON_IPEN = low ; low priority interrupt, PIC16 compatibility
>>>>>> INTCON_GIE = high   ; enable global interrupts
>>>>>> INTCON_PEIE_GIEL = high  ; enable pheripheral interrupts
>>>>>> INTCON3_INT1IE = high    ; enable INT1 on pin_RB5
>>>>>> INTCON2_INTEDG1 = high   ; enable interrupt on rising edge
>>>>>>
>>>>>>
>>>>>> forever loop
>>>>>> -- use MY_flag for whatever
>>>>>> -- reset MY_flag
>>>>>> end loop
>>>>>>
>>>>>>
>>>>>> On Sat, Sep 24, 2022 at 9:33 PM hans <[email protected]> wrote:
>>>>>>
>>>>>>> Hi Rob,
>>>>>>> I did with the attached file in another pcd-set with no other 
>>>>>>> things. The led wichh gives the pulses show a regular (1 sec) blink but 
>>>>>>> the 
>>>>>>> output from the interrupt goes on and something off.
>>>>>>> Hans
>>>>>>>
>>>>>>> Op zaterdag 24 september 2022 om 20:04:23 UTC+2 schreef 
>>>>>>> [email protected]:
>>>>>>>
>>>>>>>> Hi Hans,
>>>>>>>>
>>>>>>>> I see that this PIC has interrupts with prioirities.
>>>>>>>>
>>>>>>>> Since you only use interrupt 0 as a regular interrupt can you 
>>>>>>>> change this (make FALSE instead of TRUE):
>>>>>>>>
>>>>>>>> INTCON_PEIE = FALSE 
>>>>>>>>
>>>>>>>> If I look in the schematic diagram of the datahseet, setting this 
>>>>>>>> to TRUE enables the other priority interrupt vector but it does not 
>>>>>>>> have 
>>>>>>>> any effect on INT0. 
>>>>>>>>
>>>>>>>> Not sure if it helps but you can give it a try.
>>>>>>>>
>>>>>>>> Kind regards,
>>>>>>>>
>>>>>>>> Rob
>>>>>>>>
>>>>>>>> ------------------------------
>>>>>>>> *Van:* [email protected] <[email protected]> namens 
>>>>>>>> hans <[email protected]>
>>>>>>>> *Verzonden:* zaterdag 24 september 2022 19:19
>>>>>>>>
>>>>>>>> *Aan:* jallib <[email protected]>
>>>>>>>> *Onderwerp:* Re: [jallib] Re: 18F4520 interrupt
>>>>>>>>  
>>>>>>>> My last try. Loaded in another set. On the output from A 1 shows a 
>>>>>>>> led a steady on/off. So also at the entrance of B4. The led on A0 
>>>>>>>> flashes 
>>>>>>>> very fast but there is no connection with the input
>>>>>>>>
>>>>>>>> Op zaterdag 24 september 2022 om 10:39:51 UTC+2 schreef hans:
>>>>>>>>
>>>>>>>> Hi Rob, 
>>>>>>>> I did already but no result. A led in the interrupt and one on the 
>>>>>>>> pinB4. The last one shows the action but the led inside teh pragme not.
>>>>>>>>  I have now made an procedure which i am calling on several places 
>>>>>>>> in my program and it worked.
>>>>>>>> procedure DTMF_receive is
>>>>>>>>            if portD_low != DTMF_old then
>>>>>>>>              DTMF = portD_low
>>>>>>>>            end if
>>>>>>>>  end procedure
>>>>>>>>
>>>>>>>> Op zaterdag 24 september 2022 om 09:45:51 UTC+2 schreef 
>>>>>>>> [email protected]:
>>>>>>>>
>>>>>>>> Hi Hans,
>>>>>>>>
>>>>>>>> The code looks OK. Maybe as a test you can activate a LED in the 
>>>>>>>> interrupt routine to check if it gets there.
>>>>>>>>
>>>>>>>> What exactly the behaviour?
>>>>>>>>
>>>>>>>> Kind regards,
>>>>>>>>
>>>>>>>> Rob
>>>>>>>>
>>>>>>>> ------------------------------
>>>>>>>> *Van:* [email protected] <[email protected]> namens 
>>>>>>>> hans <[email protected]>
>>>>>>>> *Verzonden:* zaterdag 24 september 2022 08:33
>>>>>>>> *Aan:* jallib <[email protected]>
>>>>>>>> *Onderwerp:* Re: [jallib] Re: 18F4520 interrupt 
>>>>>>>>  
>>>>>>>> I have changed the program part as follows from the example port B0 
>>>>>>>> , compiling is ok but no result 
>>>>>>>>
>>>>>>>> -- alias the interrupt flags so they are readable.
>>>>>>>> alias INT_0_ENABLE_BIT is INTCON_INT0IE
>>>>>>>> alias INT_0_FLAG_BIT is INTCON_INT0IF
>>>>>>>> alias INT_0_EDGE_BIT is INTCON2_INTEDG0
>>>>>>>>
>>>>>>>> -- enable global interrupts
>>>>>>>> INTCON_GIE  = TRUE        -- Enables all unmasked interrupts
>>>>>>>> INTCON_PEIE = TRUE        -- Enables all unmasked peripheral 
>>>>>>>> interrupts
>>>>>>>>
>>>>>>>> -- define your interrupt pin
>>>>>>>> alias interrupt_pin is pin_B4
>>>>>>>> alias interrupt_pin_direction is pin_B4_direction
>>>>>>>> interrupt_pin_direction = INPUT -- interrupt pin is input
>>>>>>>> INT_0_ENABLE_BIT = TRUE   -- interrupt pin enable bit for B0
>>>>>>>> procedure int_on_change_b0() -- procedure is written later
>>>>>>>>
>>>>>>>> -- main interrupt handler
>>>>>>>> procedure interrupt() is
>>>>>>>>    pragma interrupt
>>>>>>>>    -- Check if interrupt pin 0 (B0) has an interrupt.
>>>>>>>>    if INT_0_FLAG_BIT then
>>>>>>>>       DTMF = portD_low
>>>>>>>>       INT_0_FLAG_BIT = FALSE -- reset interrupt flag
>>>>>>>>    end if
>>>>>>>> end procedure
>>>>>>>>
>>>>>>>> a led on the interrupt pin B4 shows the short blink as soon as a 
>>>>>>>> dtmf tone is received. The received value remains on portD-low untill 
>>>>>>>> the 
>>>>>>>> next tone. So i can read it afterwards. My idea was to wait some time 
>>>>>>>> before reading the port.
>>>>>>>>
>>>>>>>> Op zaterdag 24 september 2022 om 08:08:47 UTC+2 schreef hans:
>>>>>>>>
>>>>>>>> Here is how i have started and having no reslut i did the (wrong??) 
>>>>>>>> chnages 
>>>>>>>>
>>>>>>>> -- choose pins to use for int on change
>>>>>>>> const byte int_on_change_pins[] = {"B",4}
>>>>>>>> include interrupt_on_change
>>>>>>>> int_on_change_init()
>>>>>>>>
>>>>>>>> -- interrupt for pin B4
>>>>>>>> procedure int_on_change_callback_0() is
>>>>>>>>   pragma inline
>>>>>>>>    DTMF = portD_low
>>>>>>>> end procedure
>>>>>>>>
>>>>>>>> Op zaterdag 24 september 2022 om 08:07:18 UTC+2 schreef hans:
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>> I tried to use the example in the ample sequence 18F4620 Interrupt 
>>>>>>>> on change for the 18F4520. It does not work. What's going on?
>>>>>>>> regards
>>>>>>>> Hans
>>>>>>>>
>>>>>>>> Op zaterdag 24 september 2022 om 07:42:24 UTC+2 schreef 
>>>>>>>> [email protected]:
>>>>>>>>
>>>>>>>> Hi Vasile, he is using the interrupt on change library. It has 
>>>>>>>> "pragma interrupt" and needs the strange line "const byte 
>>>>>>>> int_on_change_pins[] = {"B",4}". 
>>>>>>>>
>>>>>>>> I agree about the delay, but that depends on the use as you pointed 
>>>>>>>> out. It may be ok for the code that is there now, but another way 
>>>>>>>> would be 
>>>>>>>> to start a timer then when the timer is up use the timer interrupt to 
>>>>>>>> read 
>>>>>>>> portD_low.
>>>>>>>>
>>>>>>>> There is also sample 18f4620_interrupt_on_change_pin_b0.jal that 
>>>>>>>> shows the use of interrupt on change without using the library.
>>>>>>>>
>>>>>>>> Matt.
>>>>>>>>
>>>>>>>> On Saturday, September 24, 2022 at 1:21:09 AM UTC-4 vasile wrote:
>>>>>>>>
>>>>>>>> Hans,
>>>>>>>> I do not see any "pragma interrupt",  it's that OK?
>>>>>>>> An interrupt procedure needs it no matter the name it has, without 
>>>>>>>> it there would be no jump to the ISR interrupt vector.
>>>>>>>>
>>>>>>>> This line looks strange to me here (but I'm not a master of 
>>>>>>>> programming):
>>>>>>>> const byte int_on_change_pins[] = {"B",4} 
>>>>>>>>
>>>>>>>> BTW, you do not want to use a software delay in an ISR routine, an 
>>>>>>>> ISR must be fast by definition because it consumes a period of time 
>>>>>>>> which 
>>>>>>>> is lost in the main loop. Exceptions for hardware resources of which 
>>>>>>>> programming time do not interfere too much with the main loop. Check 
>>>>>>>> if 
>>>>>>>> your pic has registers to detect which edge is used on interrupt on 
>>>>>>>> change. 
>>>>>>>> If yes you should program those too.
>>>>>>>>
>>>>>>>> I hope these would be helpful. In my opinion you should solve the 
>>>>>>>> problem by yourself, is the only way you can understand.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sat, Sep 24, 2022 at 8:03 AM Matthew Schinkel <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>> Hi Hans, without me testing or knowing the DTMF module your using. 
>>>>>>>> I think it looks ok. It should be easy to test. 
>>>>>>>>
>>>>>>>> Just to make your code easier to read I would alias the pins and 
>>>>>>>> directions to useful names. You read code 10 times more than you write 
>>>>>>>> it. 
>>>>>>>> I don't know what pin_C3 is for, and pin_C3_direction isn't being set.
>>>>>>>>
>>>>>>>> Looks like your code will wait for an interrupt on pin_B4 then read 
>>>>>>>> the lower 4 bits of portd
>>>>>>>>
>>>>>>>> If the original sample works for you, you can add a sample 
>>>>>>>> for 18F4520. The library may need to be modified to support more chips.
>>>>>>>>
>>>>>>>> Matt.
>>>>>>>>
>>>>>>>> On Friday, September 23, 2022 at 12:44:59 PM UTC-4 hans wrote:
>>>>>>>>
>>>>>>>> The basic file: 
>>>>>>>>
>>>>>>>>   include 18f4520                     -- target PICmicro
>>>>>>>> --
>>>>>>>> -- This program uses the internal oscillator at 4 MHz.
>>>>>>>> pragma target clock    4_000_000       -- oscillator frequency
>>>>>>>> --
>>>>>>>> pragma target OSC      INTOSC_NOCLKOUT           -- internal 
>>>>>>>> oscillator
>>>>>>>> pragma target WDT      CONTROL                   -- watchdog
>>>>>>>> pragma target XINST    DISABLED                  -- do not use 
>>>>>>>> extended instructionset
>>>>>>>> pragma target DEBUG    DISABLED                  -- no debugging
>>>>>>>> pragma target BROWNOUT DISABLED                  -- no brownout 
>>>>>>>> reset
>>>>>>>> pragma target FCMEN    DISABLED                  -- no clock 
>>>>>>>> monitoring
>>>>>>>> pragma target IESO     DISABLED                  -- no int/ext osc 
>>>>>>>> switching
>>>>>>>> pragma target LVP      DISABLED                   -- low voltage 
>>>>>>>> programming
>>>>>>>> pragma target MCLR     EXTERNAL                  -- external reset
>>>>>>>> --
>>>>>>>> -- The configuration bit settings above are only a selection, 
>>>>>>>> sufficient
>>>>>>>> -- for this program. Other programs may need more or different 
>>>>>>>> settings.
>>>>>>>> --
>>>>>>>> WDTCON_SWDTEN = OFF                 -- disable WDT
>>>>>>>> OSCCON_SCS = 0                      -- select primary oscillator
>>>>>>>> OSCCON_IRCF = 0b110                 -- 4 MHz
>>>>>>>> OSCTUNE_PLLEN = FALSE               -- no PLL
>>>>>>>> --
>>>>>>>> enable_digital_io()                 -- make all pins digital I/O
>>>>>>>> --
>>>>>>>>
>>>>>>>> -- DTMF programma
>>>>>>>> pin_D0_direction       = input
>>>>>>>> pin_D1_direction       = input
>>>>>>>> pin_D2_direction       = input
>>>>>>>> pin_D3_direction       = input
>>>>>>>> pin_B4_direction       = input -- for interrupt
>>>>>>>>
>>>>>>>>
>>>>>>>> var byte DTMF
>>>>>>>>
>>>>>>>>
>>>>>>>> -- choose pins to use for int on change
>>>>>>>> const byte int_on_change_pins[] = {"B",4}
>>>>>>>> include interrupt_on_change
>>>>>>>> int_on_change_init()
>>>>>>>>
>>>>>>>> -- interrupt for pin B4
>>>>>>>> procedure int_on_change_callback_0() is
>>>>>>>>    pragma inline
>>>>>>>>    pin_C3 = low
>>>>>>>>    delay_1mS(400)
>>>>>>>>    DTMF = portD_low
>>>>>>>>    pin_C3 = high
>>>>>>>> end procedure
>>>>>>>>
>>>>>>>>
>>>>>>>> Op vrijdag 23 september 2022 om 14:59:53 UTC+2 schreef hans:
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>> I am trying to read a DTMF module with an interrupt on a 
>>>>>>>> 18F4520.pin B4. I found something in the examples. Is thissufficient 
>>>>>>>> and  
>>>>>>>> correct? Direct reading of portD_low is working correct.  
>>>>>>>>
>>>>>>>> -- choose pins to use for int on change
>>>>>>>> const byte int_on_change_pins[] = {"B",4}
>>>>>>>> include interrupt_on_change
>>>>>>>> int_on_change_init()
>>>>>>>>
>>>>>>>> -- interrupt for pin B4
>>>>>>>> procedure int_on_change_callback_0() is
>>>>>>>>    pragma inline
>>>>>>>>    delay_1mS(400)
>>>>>>>>    DTMF = portD_low
>>>>>>>> end procedure
>>>>>>>> regards
>>>>>>>> Hans
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "jallib" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/jallib/df18aa34-b7fc-4d5d-bfe5-65e1a4b741d9n%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jallib/df18aa34-b7fc-4d5d-bfe5-65e1a4b741d9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "jallib" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/jallib/f9987acb-6a37-40e6-8f36-d32046365d44n%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jallib/f9987acb-6a37-40e6-8f36-d32046365d44n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "jallib" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/jallib/45e0a656-9db6-45c6-b583-5ea2a7597bf6n%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/jallib/45e0a656-9db6-45c6-b583-5ea2a7597bf6n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "jallib" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>>
>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/jallib/722bfca5-af9b-4839-8857-f8484e827aabn%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/jallib/722bfca5-af9b-4839-8857-f8484e827aabn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "jallib" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>>
>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/jallib/bd0cd083-5a54-44e0-a727-2ec4bbe79547n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/jallib/bd0cd083-5a54-44e0-a727-2ec4bbe79547n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "jallib" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jallib/1a80e651-8371-4c87-ac4c-6a86681d99cdn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jallib/1a80e651-8371-4c87-ac4c-6a86681d99cdn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/3448ce99-8996-428f-b0c6-0a6e048b5339n%40googlegroups.com.

Reply via email to