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/01bdef48-6fb3-4b75-8de6-8483c9cde017n%40googlegroups.com.

Reply via email to