News:

Let's find out together what makes a PIC Tick!

Main Menu

18F05Q41 PPS

Started by joesaliba, Oct 11, 2024, 07:58 PM

Previous topic - Next topic

trastikata

#20
Quote from: top204 on Oct 15, 2024, 01:04 PMWith an INTx peripheral, the flag will not set if the INTx peripheral is not enabled.

Les, actually it will. I've known it as a fact and assumed it will set the flag but never have actually tested it till now. A simple code with a LED and wire to toggle the PORTB.0 pin to test the case, confirmed it.

    INTCON.1 = 0    'clear INT0IF
    INTCON2.6 = 1   'INTEDG0 - interrupt on rising edge
    Input PORTB.0   'Set pin INT0 as input
    Output PORTA.4  'LED output
    Low PORTA.4     'Low LED
   
    While 1 = 1
        If INTCON.1 = 1 Then    'Check if INT0IF is set
            High PORTA.4        'High LED
            DelayMS 2000        'Wait 2s
            Low PORTA.4         'Low LED     
            INTCON.1 = 0        'Clear INT0IF
        EndIf
    Wend  

Same goes for RB Port Change Interrupt Flag.

Frizie

This is correct Trastikata.
I often use that when an interrupt is not needed I use the flag without an interrupt happening.
It is also stated that way in the datasheet as far as I remember.
Ohm sweet Ohm | www.picbasic.nl

top204

#22
Many thanks trastikata. I did not realise that happened.

I have always enabled the interrupt when using an INT peripheral, so never checked it without it enabled.

joesaliba

Yes, I just retested, and that what is happening, and that why I was baffled.

Before I was using a 18F14K22 and did not had this `problem', so I thought I was doing something wrong with the 18F05Q41.

As I said, I saw a few programs using the AND on other forums to make sure this unintentional interrupt does not happen, which, programming wise will be standard from now on for me.

Thank you
Kind regards

Joe

JonW

I think this is pretty normal and is definitely not just on PICs. I have used Padauk, Nyquest, Tenx, and RiscV MCUs and using int flags without vectoring to the ISR for very tight loops.

top204

The amount of years I have used microcontrollers, and I never thought of testing the INT flag without an interrupt enabled!

I'll try some tests on the IOC (Interrupt On Change) peripheral without the main interrupt occuring, and if it is the same as the INT peripheral, it should set the flag when a pin's state is altered. This should come in handy because the newer devices allow any pin to be set as an IOC, so a pin change can be checked even after it has been physically pressed and missed by the program's cycle.