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

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.

Another querk of the PIC chips uncovered. LOL.