Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Post

    Hi,

    No surprise if you read the interrupt sources list

    #define INT_INT INTCON,INT0IF ;-- INT External Interrupt, 16F compatible
    #define INT0_INT INTCON,INT0IF ;-- INT0 External Interrupt
    #define INT1_INT INTCON3,INT1IF ;-- INT1 External Interrupt
    #define INT2_INT INTCON3,INT2IF ;-- INT2 External Interrupt
    #define INT3_INT INTCON3,INT3IF ;-- INT3 External Interrupt
    #define RBC_INT INTCON,RBIF ;-- RB Port Change Interrupt
    #define TMR0_INT INTCON,TMR0IF ;-- TMR0 Overflow Interrupt 18F
    #define TMR1_INT PIR1,TMR1IF ;-- TMR1 Overflow Interrupt
    #define TMR2_INT PIR1,TMR2IF ;-- TMR2 to PR2 Match Interrupt
    #define TMR3_INT PIR2,TMR3IF ;-- TMR3 Overflow Interrupt
    #define TMR4_INT PIR3,TMR4IF ;-- TMR4 Overflow Interrupt
    #define TX_INT PIR1,TXIF ;-- USART Transmit Interrupt
    #define TX1_INT PIR1,TX1IF ;-- USART1 Transmit Interrupt
    #define TX2_INT PIR3,TX2IF ;-- USART2 Transmit Interrupt
    #define RX_INT PIR1,RCIF ;-- USART Receive Interrupt
    #define RX1_INT PIR1,RC1IF ;-- USART1 Receive Interrupt
    #define RX2_INT PIR3,RC2IF ;-- USART2 Receive Interrupt
    #define CMP_INT PIR2,CMIF ;-- Comparator Interrupt
    #define EE_INT PIR2,EEIF ;-- EEPROM/FLASH Write Operation Interrupt
    #define BUS_INT PIR2,BCLIF ;-- Bus Collision Interrupt
    #define LVD_INT PIR2,LVDIF ;-- Low Voltage Detect Interrupt
    #define HLVD_INT PIR2,HLVDIF ;-- High/Low Voltage Detect Interrupt
    #define PSP_INT PIR1, PSPIF ;-- Parallel Slave Port Read/Write Interrupt
    #define AD_INT PIR1, ADIF ;-- A/D Converter Interrupt
    #define SSP_INT PIR1, SSPIF ;-- Master Synchronous Serial Port Interrupt
    #define CCP1_INT PIR1, CCP1IF ;-- CCP1 Interrupt
    #define CCP2_INT PIR2, CCP2IF ;-- CCP2 Interrupt
    #define CCP3_INT PIR3, CCP3IF ;-- CCP3 Interrupt
    #define CCP4_INT PIR3, CCP4IF ;-- CCP4 Interrupt
    #define CCP5_INT PIR3, CCP5IF ;-- CCP5 Interrupt
    #define USB_INT PIR2, USBIF ;-- USB Interrupt
    #define OSC_INT PIR2, OSCFIF ;-- Oscillator Fail Interrupt



    ... only this :

    #define CMP_INT PIR2,CMIF ;-- Comparator Interrupt

    I think you have Yourself to look from which comparator the interrupt comes ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi Alain

    Thankyou Alain for taking the trouble to read my post and make a suggestion, may I draw your attention to the defines further down Darrel's wonderful coding.

    ;_____ Comparators __________________________________________________ ________
    #define CMP0_INT PIR1, CMP0IF ;-- Comparator 0 - 1230/1330 only

    CMPIFREG = PIR2 ;-- Comparator 1
    CMPIEREG = PIE2
    CMPIPREG = IPR2
    ifdef C1IF ; 18F24K20 18F25K20 18F26K20
    CM1IFBIT = C1IF ; 18F44K20 18F45K20 18F46K20
    endif
    ifdef CM1IF
    CM1IFBIT = CM1IF ; several J PICs
    endif
    ifdef CMP1IF
    CMPIFREG = PIR1 ; 1230/1330 only
    CM1IFBIT = CMP1IF
    CMPIEREG = PIE1
    CMPIPREG = IPR1
    endif

    ifdef CM1IFBIT
    #define CMP1_INT CMPIFREG, CM1IFBIT
    endif

    ifdef C2IF ;-- Comparator 2
    CM2IFBIT = C2IF ; 18F24K20 18F25K20 18F26K20
    endif ; 18F44K20 18F45K20 18F46K20
    ifdef CM2IF
    CM2IFBIT = CM2IF ; several J PICs
    endif
    ifdef CMP2IF
    CM2IFBIT = CMP2IF ; 1230/1330 only
    endif

    ifdef CM2IFBIT
    #define CMP2_INT CMPIFREG, CM2IFBIT
    endif
    '-----------------------------------------------------------------------------

    I think we are all waiting for the "K" series, perhaps this will compile to the K. I shall try it.

    I did wonder wether I should set the ADCON for this device particularily the LATA register. But I am also aware that <6> of the PIR2 PIE2 and IPR2 only refers to one CMI, I presume I shall have to be careful to make sure that any interrupt on either comparator does not interfere with the other. ie if one comparator is set then the other is disabled.

    Thanks again for your help.

    Duncan

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The difference is that on the 4520, there is only 1 interrupt source for the Comparator module. A change in either comparator will cause an interrupt to the same handler.

    There are other chips that have individual interrupt flags for each comparator, but not the 4520.

    So you need to use the CMP_INT, on that chip.
    <br>
    DT

  4. #4
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Thanks for reply, I had slowly worked my way towrds that.

    for th 18F45K20 Migration
    The comparator is no longer controlled by the
    CMCON register and each comparator now has it’s
    own control register, CM1CON and CM2CON. The
    functionality of the bits has also changed.

    there is a section that confirms the observations made about the registers, so it really does always boil down to RTFD, but reading is sometimes not enough if you suffer from word blindness, anyway it gave me the opportunity to say thankyou for your routines which I intend to use.

    Duncan.

    Furthermore if everybody read and fully "understood" the datasheets this forum would die.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    ... thankyou for your routines which I intend to use ...
    Grrreat! Hope the rest works out OK.
    If not, let me know.

    Furthermore if everybody read and fully "understood" the datasheets this forum would die.
    Or, then we could actually talk about the real purpose of this forum.
    Programming with PicBasic Pro.
    <br>
    DT

  6. #6
    Join Date
    Feb 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default POT & RCTIME works with DT_INTS-14.bas?

    Hi Darrel,

    this is my first post on this comunity. First of all I would thanks for the fantastic DT_INTS-14.bas background PWM routine.

    I have uset your SW on a 16F628 in order to drive some LED with different brightness an WORK PEFECTLY. Darrel YOU ARE GREAT!!!!!

    Now I need to use a potentiometer so set at run time the brightnes value for the LEDs, and after reading tons of html page and googled for hours, I have the founded suspect that the PBP instruction POT and RCTIME do not work with DT_INTS-14.bas.

    Can you please confirm?

    Ciao

    Leo

  7. #7
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Leo,
    Any time you have a routine or command that counts time, an interrupt will cause the timing to be off. Since the POT command times the discharge time of a cap, an interrupt in the middle of it will cause the command to give you a faulty reading when it is resumed.

    There are several options;
    --turn off the interrupts just before your POT command (and any other timing-specific command), and restore them just after.
    --write yourself a home-made "pot" command, and use it inside the interrupts (but this only works if your interrupts are high frequency.)
    --use a "real" a/d converter, either one in the PIC or off the chip.

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 8

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts