Skip to main content
Visitor II
March 7, 2007
Question

re entering of interrupts

  • March 7, 2007
  • 10 replies
  • 1365 views
Posted on March 08, 2007 at 00:04

re entering of interrupts

    This topic has been closed for replies.

    10 replies

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:37

    Hi all,

    I solved the above problem with a slight change in the ISR as shown below:

    __irq void RTC_ISR(void)

    {

    k=1;

    tmp = RTC->SR; // clear RTC Periodic Interrupt flag

    VIC1->VAR=0; // dummy write to Vector Address Register

    while (VIC1->VAR !=0);

    RTC->CR = 0x00200000; // 128Hz Periodic interrupt disabled

    RTC->CR = 0x00240000; // 128Hz Periodic interrupt selected

    }

    I don't know whether I can disable and enable the periodic interrupt every time the interrupt occurs, but it has worked. Can anybody please tell me whether I can do this or not?

    Regards,

    Neelima.

    :D

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:37

    Hai all,

    In my code for RTC periodic interrupt, the ISR is becomming reentrant. in the execution profile i've observed that thte VIC1->VAR register is not resetting after the assaignment. My code is:

    #include

    void CMP_Configuration(void);

    __irq void RTC_ISR(void);

    u8 k=0;

    vu32 tmp;

    void main()

    {

    u8 d=0x00;

    #ifdef DEBUG

    debug();

    #endif

    CMP_Configuration();

    while(1)

    {

    if (k==1)

    {

    k=0;

    GPIO7->DR[0x3FC] = ~d;

    }

    }

    }

    /********************************Subroutines******************************/

    void CMP_Configuration(void)

    {

    /********************* VIC Configuration******************************/

    VIC1->VAiR[0] = (unsigned int)RTC_ISR; // Interrupt vector address = ISR

    VIC1->INTSR = 0x00; // RTC interrupt is IRQ type

    VIC1->VCiR[0] = 0x28; // RTC interrupt configured at 0 priority

    VIC1->INTER |= 0x0100; // RTC interrupt enabled.

    /*************************RTC Configuration***************************/

    RTC->CR |= 0x80; // Write enable date, time and milli second registers

    RTC->DTR = 0x20070202; // Date initialization

    RTC->TR = 0x12154552; // Time initialization

    RTC->MILR = 0x00000000; // Milli Second Initialization

    RTC->CR &= ~0x80; // Write disable date, time and milli second registers

    RTC->CR = 0x00240000; // 128Hz Periodic interrupt selected

    tmp = RTC->SR; // Clear RTC Periodic Interrupt Flag

    /*************************GPIO7 Configuration****************************/

    GPIO7->DDR |= GPIO_Pin_All; // All pins in GPIO7 are o/p pins

    SCU->GPIOOUT[0x07] = 0x5555;//O/pis of general purpose type(alternate o/p1)

    SCU->GPIOTYPE[0x07]= 0X0000; // All pins are of push-pull type

    SCU->GPIOIN[7] = 0x0000; // IP connection disabled.

    }

    __irq void RTC_ISR(void)

    {

    k=1;

    tmp = RTC->SR; // clear RTC Periodic Interrupt flag

    VIC1->VAR=0; // dummy write to Vector Address Register

    }

    If I modify the ISR like shown below, it is properly working but with a

    long delay.

    __irq void RTC_ISR(void)

    {

    k=1;

    tmp = RTC->SR; // clear RTC Periodic Interrupt flag

    VIC1->VAR=0; // dummy write to Vector Address Register

    while (VIC1->VAR !=0);

    }

    Can any body give me the solution? please, it is very urgent.

    Regards,

    Neelima

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Could i ask - what behaviour/functionality are you after ?

    putting a while loop, eg. while (VIC1->VAR !=0); in a interrupt routine is not a wise thing todo.

    Regards

    sjo

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Hi sjo,

    I need to generate an RTC periodic interrupt for every 15.625 msec. Don't go with the first code. Pleasetell me whether the modified code is viable or not.

    Regards,

    Neelima. :o

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Quote:

    Could i ask - what behaviour/functionality are you after ?

    putting a while loop, eg. while (VIC1->VAR !=0); in a interrupt routine is not a wise thing todo.

    Regards

    sjo

    I had the same problem:

    http://mcu.st.com/mcu/forums-cat-4996-21.html

    The while loop executes only once so it is useless but doesn't hurt either!

    this is the irq handler from example given by Mirou:

    void RTC_IRQHandler(void)

    {

    vu32 tmp = 0;

    RTC_ITConfig(RTC_IT_Per, DISABLE); //disable RTC Periodic interrupt

    RTC->CR &=~0xF0000; //clear PISEL field

    tmp=RTC->SR; //read the SR register

    GPIO_WriteBit(GPIO0,GPIO_Pin_7,Bit_SET);

    GPIO_WriteBit(GPIO0,GPIO_Pin_7,Bit_RESET);

    RTC_PeriodicIntConfig(RTC_Per_1024Hz);

    RTC_ITConfig(RTC_IT_Per, ENABLE); //reenable Periodic interrupt

    }

    As explained in my original post I think the

    RTC_ITConfig(RTC_IT_Per, DISABLE); //disable RTC Periodic

    tmp=RTC->SR; //read the SR register

    RTC_ITConfig(RTC_IT_Per, ENABLE); //reenable Periodic interrupt

    is not necessary!

    regards,

    Andras

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Hi Andras,

    I dont think it reasonable to reinitialize the periodic interrupt every time. It changes the whole idea of the RTC interrupt being periodic. But I doubt whether it is viable to reinitialize the period of interrupt( the frequency selection part). Please clear my doubt.

    Check the code I've used with the modified IRQ. It is working well.

    Regards,

    Neelima.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Hi Neelima,

    >I dont think it reasonable to reinitialize the periodic interrupt every time

    That was my point too, the only difference is I don't think you really need the while loop either. My experience is that changing only the PISEL bits does not alter the counter itself.

    regards,

    Andras

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:38

    Hi Andras,

    Thankyou for the reply. My doubt is whether we need to reinitialize the PISEL bits evry time. Can't the periodic interrupt be working well without this part. Please clear my doubt.

    Regards,

    Neelilma.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:39

    Hi Neelilma,

    >My doubt is whether we need to reinitialize the PISEL bits evry time

    I need sure enough!

    I consider this a silicon bug, and expect to see it listed in next errata. Fortunately it has this workaround and is not a so big deal (max 5 instruction + 3 constant).

    Last errata was issued on 5.feb.2007 but this issue popped up only on 15.feb.2007. So maybe we have to wait a while for official confirmation.

    regards,

    Andras

    nanuradhaAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:39

    Hi Andras,

    Thnkyou for the support and as u said, I too suppose we have to wait a while for official confirmation.

    regards,

    Neelima.