Hi Rob,
Perhaps you should disable/enable interrupts within the I2c procedures and
not for the entire main program.
The way you did it, by writing a flag in the ISR and reading it in the main
is correct. If you need less delay between the main execution and interrupt
flag refresh, you should have just one interrupt routine and keep it as
short as possible. Nowadays the JAL libraries are using multiple ISR's
which are controlled entirely by the compiler. This feature does not give
too many options to the user except writing his own procedures for
sensitive interrupt applications instead of using libraries with their own
ISR's.

best wishes

On Thu, Jun 1, 2023 at 9:34 PM rob...@hotmail.com <rob...@hotmail.com>
wrote:

> Hi all,
>
> I have the following issue and I am interested in either your suggestions
> or if you encountered the same problem. The example is based on the sample
> program I made for the real time clock library DS3231.
>
> The DS3231 has two alarms and uses the IIC interface. The device has an
> interrupt line that can be activated when an alarm is triggered. I
> connected this line to the external interrupt of the PIC.
>
> The main program read the time and sends it to the serial port. Since the
> main program calls DA3231 functions, the IIC interface is used to access
> the DS3231. When an interrupt occurs, a register has to be read from the
> DS3231 to see which alarm was activated also using the IIC interface of
> course.
>
> In order to prevent that halfway an IIC transmission initiated by a
> library call from the main program, I disable the external interrupt of the
> PIC at the start of the main program an enable it again at the end of the
> main program. In that way I am sure that the interrupt does not interrupt
> an IIC transmission initiated by the main program. There is a delay at the
> end of the main program, sufficient for any pending interrupt to be handled.
>
> The problem is that it does not work. The PIC just hangs and does not
> start. The only solution I found is setting a flag in the interrupt routine
> and let the main program poll this flag and read the register from the
> DS3231 to check which alarm was activated. But in this way the whole idea
> of the interrupt is gone.
>
> Looking forward to your reactions and suggestions.
>
> Thanks.
>
> Kind regards,
>
> Rob
>
>
>
> --
> 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 jallib+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jallib/679a0f81-03fe-4310-b401-ac69f2d2aeadn%40googlegroups.com
> <https://groups.google.com/d/msgid/jallib/679a0f81-03fe-4310-b401-ac69f2d2aeadn%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 jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/CAM%2Bj4qt%3DKi2pGVDwyLkzHmZJAsaX0qkoQPxM-p580W4BC%3DKNMw%40mail.gmail.com.

Reply via email to