cancel
Showing results for 
Search instead for 
Did you mean: 

External interupt

michel239955_st
Associate II
Posted on February 23, 2008 at 16:31

External interupt

6 REPLIES 6
michel239955_st
Associate II
Posted on May 17, 2011 at 09:49

Hi,

I finaly pass thrue the interupt process and made it work. This is not an easy way so I try to explain it here. May be this will help another one at his first attemp with the STR9 interupt process.

First the doc is not quit clear. I succeed by reading many doc , forum and ask question and a little bit of guessing.

Here's what i had to do. I use an external pin p5.6 to generate an interrupt on a REVA board from Raisonance the MCU board is an STR912F.

First thing to do is to program the port (5 in my case) in input at least the pin you will use.

//GPIO5 init (pin 0-3 N/A)

SCU->PRR1 |= 0x00080000; // release P5 reset

SCU->PCGR1 |= 0x00080000; // clock gating P5

SCU->GPIOIN[5] |= 0x00; //p5.6 = intr 14(normal input for port 5 pin)

GPIO5->DIR = 0x00; // Dir input on GPIO5 for pins 0-7

Second is to understand that the interupt signal pass thrue the wake up unit (WUI) to go in the VIC (Vector interupt controler) so you have to enable it.

// Clock for WIU (Enable WIU)

SCU->PRR1 |= 0x00002000; // release WIU reset

SCU->PCGR1 |= 0x00002000; // clock gating WIU

You also have to enable the VIC

// Clock for VIC (enable VIC)

SCU->PRR0 |= 0x0020;

SCU->PCGRO |= 0x0020;

The wui will transfert only one pin of the port to the VIc so you have to select it.

// Connect Pin P5.6 to VIC1.11 chanel

SCU->WKUPSEL &= 0xFFF7;

SCU->WKUPSEL |= 0x0030;

then you program the adress of the interupt routine in the Vic register

// Put the interupt adress in the VAiR 11 register

VIC1->VAiR[11] = (unsigned int)&interrupt_handler;

note the '&' before the subroutine name

now I chose witch interupt IRQ or FIQ it will generate and enable the vic vector

VIC1->INTSR &= 0xF7FF; // Generate IRQ instead of FIQ '0' for vic1.11

VIC1->VCiR[11] &= 0xFFC0;

VIC1->VCiR[11] |= 0x002B; // enable interupt with vector 11

Then I Finish to program the WUI unit:

//program the WIU to transfer interrupt to the vic

WIU->PR |= 0xFFFFFFFC; //Clear pendind interupt

WIU->CTRL |= 0x02; //Global WIU intr enable

WIU->MR |= 0xFFFFFFFC; //Accept external interupt

Finaly I enable interup:

VIC1->INTER |= 0x0800; // Enable interupt 11 du vic 1

I run the program and when a faling edge on P5.6 pin apend the interupt subroutine is call.

Note : on the interup subroutine you have to clear the interupt

void interrupt_handler (void)

{

//dummy code

count++;

WIU->PR |= 0xFFFFFFFC; //Clear pendind interupt

VIC1->VAR = 0; // Clear interupt

}

I hope that will help some of new one with STR9. If you have any comment and some explanation please do so

Thank you

Mike 8-)

michel239955_st
Associate II
Posted on May 17, 2011 at 09:49

I try to use external pin P5.6 to generate an interup but the interupt never apend.

I use REVA board with STR912F MCU

I'm working in debug

Here my code:

#include ''STRx.h''

int delaycnt;

int k;

void interrupt_handler (void);

...

...

function

...

...

void interrupt_handler (void)

{

int i,l;

i=1;

l=i;

VIC1->VAR = 0;

}

int main()

{

int i;

int status = 0;

int cote = 0;

int size = 0;

int suivant = 0;

int timerst = 0;

int timerval = 0;

int timerval2 = 0;

float volt;

mg=0;

//init device

initcpu(); //initialise GPI0 0 to 9

// Interupt init

// Clock for VIC

SCU->PRR0 |= 0x0020;

SCU->PCGRO |= 0x0020;

// Connect Pin P5.6 to the external interupt 1

SCU->WKUPSEL &= 0xFFF7;

SCU->WKUPSEL |= 0x0030;

VIC1->VAiR[11] = (unsigned int)interrupt_handler;

VIC1->VCiR[11] = 0x20; // enable interupt vector

VIC1->VCiR[11] |= 0x0B; // specify interupt number

VIC1->INTSR = 0x0000; // Generate IRQ instead of FIQ

VIC1->INTER = 0x0800; // Enable interupt 11 du vic 1

VIC1->VAR = 0; // Acknowledge Interrupt

do

{

i =2;

}

while (i = 2);

...

code

...

}

The port 5 is put in input modes as follow:

//GPIO5 init (pin 0-3 N/A)

SCU->PRR1 |= 0x00080000; // release P5 reset

SCU->PCGR1 |= 0x00080000; // clock gating P5

SCU->GPIOIN[5] |= 0x00; //P5.6 = intr 14 default

GPIO5->DIR = 0x00; // Dir input on GPIO5 for pins 0-7

I put a breakpoint in the interupt code but it never hapend.

What is wrong. It should work ???????

help please

Mike

nik
Associate II
Posted on May 17, 2011 at 09:49

Bonjour Michel,

I worked out a similar config. But there is something that really bothers me: as soon as I recover GPIO5 from reset and enable clocking, all pins but 5.3 switch to ''High''.

I have the Keil MCBSTR9 with STR912FAW using uVision3. Even when I change the status manually via the Peripheral menu, it changes back the very next pulse.

Actually, an interrupt is not really needed for my application. All there is to be done is check, whether a switch is closed or not:

P5.6 (output set to 1) -----/ ----- P5.7 (input)

Now my programme checks the status of 5.7. But due to the problem mentioned above, the pin is always high...

Does anyone have an idea on this?

Cheers

Nik

michel239955_st
Associate II
Posted on May 17, 2011 at 09:49

I still work on my interup software and I have some more info to share.

As far as i know, pin of port 5 will be conect to the vic 1.11 port 6 to vic 1.12 port 7 - vic 1.13 and port 3 to vic 1.10. It means that only one pin of each port is available for interup in a moment.

It's possible to chose the Rising or falling edge of the interupt signal in writing on the WUI_TR register.

WIU->TR |= 0x0000; //triger polarity 0 falling 1 rising

it is possible to change the priority of each interup routine with the VICx_VCiR[xx] number but I don't know exactly how it's work. I made some experiment but I dont have any sure conclusion

VIC1->VCiR[11] |= 0x002B; // enable interupt with vector 11

VIC1->VCiR[11] |= 0x002A; // enable interupt with vector 10

If someone could explain I'll apreciate. Also why is there 5 bit in the VCiR register to select the interup source 4 had been enough?

In my program I made general programation by it could be more specific

ex: WIU->MR |= 0xFFFFFFFC; //Accept external interupt

you could be more precise ex WIU->MR |= 0x000010C;

If someone have more detail please do so. We will apreciate your help.

Mike

8-)

michel239955_st
Associate II
Posted on May 17, 2011 at 09:49

I already meet this problem. I was working with Ride ver 6.0. As soon as i put the pin in output mode with the command (SCU->GPIOOUT[5] |= 0x5555;)i couln't return it to input mode SCU->GPIOOUT[5] |= 0x0000. I send a request to technical support but didn't find any answer. I install the version 7 of ride software and the problem disapear for the 2 version. I couln't explain it. May be there was a bad driver...

Hope this will help you

e-mail3
Associate
Posted on May 17, 2011 at 09:49

Hi Michel,

I only want to show you a little misstake.

If you code SCU->GPIOOUT[5] |= 0x5555; and try to reset it with SCU->GPIOOUT[5] |= 0x0000; this won't work because you use the OR | Operator.

ex: 1|0=1

If you want to reset it, use SCU->GPIOOUT[5] = 0x0000;

If you only want to reset Pin 0, use SCU->GPIOOUT[5] &= ~0x0003;

I hope this can help you. If not, keep on trying.