GPIO interrupts lock forground...

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Folks,

Doing a UC3C project and having no luck figuring out this problem.

Using info here, and general posting s on the web, I'm pretty sure my code if OK.

I've checked out the hardware, and when polled, the GPIO is in fact changing.

But, when I try this under interrupt control, the foreground locks.  I don't know where the code has wandered off to, as I can't get my JTAGICE3 to actually enter debug mode.

All I can say is that foreground stops, and the LED on command in the ISR never lights the LED.

Here is the GPIO code, anyone have any ideas?:

 

ISR( position_sensor_int_handler_G12, AVR32_GPIO_IRQ_12, AVR32_INTC_INT2 )
{
    if( gpio_get_pin_interrupt_flag( QC3 ) )
    {        // PD14 generated the interrupt.
        gn_PosDir[3] = gpio_get_pin_value(QD3);
        if ( gn_PosDir[3] ) {gn_PosCnt[3]++;}
        else {gn_PosCnt[3]--;}
        // Clear the interrupt flag
        gpio_clear_pin_interrupt_flag( QC3 );
    }
}

void PositionSensorInit(void)

{

    gpio_configure_pin(QD3, GPIO_DIR_INPUT);

    gpio_configure_pin(QC3, GPIO_DIR_INPUT|GPIO_PULL_DOWN);
   
    // gpio inputs: Clocks for position sensor quadrature wheels [interrupt on rising edge]
    gpio_enable_pin_interrupt(QC3, GPIO_RISING_EDGE);

    // Initialize interrupt vectors.
    Disable_global_interrupt();

    INTC_init_interrupts();

    INTC_register_interrupt( &position_sensor_int_handler_G12, AVR32_GPIO_IRQ_0+(QC3/8), AVR32_INTC_INT2); // group 12
  
    sysclk_enable_pba_module(SYSCLK_GPIO);
}

Thanks!

 

This topic has a solution.

Someone get me the hell off this rock!

Last Edited: Thu. Jun 1, 2017 - 02:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wfbrowniii_5880 wrote:
Using info here, and general posting s on the web, I'm pretty sure my code if OK.

 

Hmmm.......    some how I doubt that!   Anyway, it is pretty hard to tell given the snippets of code shown. 

Please post a small, complete project that demos the problem, then someone here will be able to run your code and point you in the right direction.

 

Jim

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

For chips as compex as UC3 you really need to use an ICE. With that you could easily "break" and find the loop that it must be stuck in.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can never understand why anyone would not have and use an "ICE" (sic) when their chip supports it!

 

surprise frown

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>>ki0bk  I'll look in to posting a project. I have not done so before. So I have no idea how to.

 

I use and ICE when I can... I program with the JTAGICE3.  however, for some reason I an not presently fathom, this board will not go in to debug mode over the JTAG interface.

 

However, using the old fashioned [circa 1980 or so] methodology I have easily available... I know where it heads to when it goes in to the weeds...

It goes to the big ISR weed collector in the sky.. or more accurately, the unregistered interrupt handler in intc.c.

 

So, I stuck this code in there to see what was going on....

    gn_interruptCause0 = AVR32_INTC.icr[AVR32_INTC_INT3 - 0];
    gn_interruptCause1 = AVR32_INTC.icr[AVR32_INTC_INT3 - 1];
    gn_interruptCause2 = AVR32_INTC.icr[AVR32_INTC_INT3 - 2];
    gn_interruptCause3 = AVR32_INTC.icr[AVR32_INTC_INT3 - 3];
    
    printf("%ld %ld %ld %ld",gn_interruptCause0,gn_interruptCause1,gn_interruptCause2,gn_interruptCause3);

 

I always get the same number printed out.  18 0 0 0

Now the kicker is that "AVR32_GPIO_IRQ_0" is in fact group 18, as is AVR32_GPIO_IRQ_0+(QC3/8).

 

Another mystery is why it is always priority level 0 even if I change to other priority levels as below:

INTC_register_interrupt( &position_sensor_int_handler_G12, (AVR32_GPIO_IRQ_0+(QC3/8)), AVR32_INTC_INT2);

and

ISR( position_sensor_int_handler_G12, AVR32_GPIO_IRQ_0, AVR32_INTC_INT2 )

at the head of the ISR...

 

Let me go look in to putting up a project.

Oh, and anyone have a guess as to why I can't get in to debug mode with the JTAGICE3"

 

Thanks again!

 

 

Someone get me the hell off this rock!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, just submitted a project.  The entire directory structure is in a big zip file.  it's called "SP platform driver"

 

Someone get me the hell off this rock!

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And I fixed it....

I was calling INTC_init_interrupts(); before every attempt at registering an interrupt handler.... that reinitializes  the table so only the last ISR gets registered.  in this case that was the comm driver.

ow it only exists in one place and it works like a charm. :)

 

I still can 't debug though. :)

 

Anyone know how to mark this as solved?

 

 

Someone get me the hell off this rock!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As you "own" this thread you should see a "Mark as solved" on each post here (alongside Quote, Edit, Reply etc). Just click that on the post where you think the thread was solved (so #7 I guess).

 

Moderator.

 

(rather stupidly the designer of this message board would not give the moderators rights to do this for users - otherwise I would have just done this for you)