We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hai, anybody is there who works on MCBSTR9 Evaluation Board.
thanks raj.
Hi RajaRao, I got some experience.
Hai Mikhail , How r u? may i know where r u from? by using MCBSTR9 board i am unable to run the external Interrupt. here i am sending my code. have a glance of this code and give u'r sugessions. #include <91x_lib.h> extern void Delay(u32 nCount); extern __irq void EXTIT0_IRQ_Handler(void); /* TIM3 interrupt routine */
int main (void) { GPIO3->DDR= 0x00; // P3 is in Input mode, P3.5,6 are used for ExtIntp GPIO7->DDR= 0xFF; // P7.0..7 Outputs for LEDs SCU->GPIOOUT[7]=0x5555;// P7 is mode 1(general purpose o/p) SCU->GPIOOUT[3]=0x0000;// P3 is mode 0(default input mode) WIU->PR= 0X04000000;// wake-up trigger event occurred WIU->CTRL |= 0X02;// enable the INT_EN bit (Intp mode) WIU->MR= 0X04000000;// enable the WIU Intp5 WIU->TR= 0X00;// enable the FALLING edge for WIU Intp5 SCU->WKUPSEL |= (1<<5);// enable the Intp5(P3.5) /* Configure and enable IRQ for ExtInt0 */ VIC1->VCiR[10] |= 0x20; /* Enable the vector interrupt */ VIC1->VCiR[10] = 0X05; /* Specify the interrupt number */ VIC1->INTER |= (1<<10); /* Enable EXTIT0 interrupt */ VIC1->INTSR= 0X00; /* ENABLE IRQ for Extint5 */ while(1) { GPIO7->DR[0x3FC]=0x03; Delay(0x0fff); } }
void Delay(u32 nCount) { u8 j; while(nCount-->0) { for(j=0;j<=50;j++); } } Interrupt routine: #include <91x_lib.h> __irq void EXTIT0_IRQ_Handler(void) { GPIO7->DR[0x3FC]=0XC3; Delay(0x0fff); }
thanks in advance regards raj.
After a cursory glance, I have some questions that may have some bearing on your problem:
1.) It appears that you are trying to use the External Interrupt pin to generate a "wake up". Where in your code was the processor (or any perihpheral) "put to sleep" in the first place? In other words...are you trying to wake up a processor that is already awake?
2.) You call a delay function from within an ISR. I realize that this program is probably a simple test and the delay in the ISR will probably not do much harm, but in the "real world". You would not want to call a delay() from within an ISR. Any reason why you didn't just set a "flag" in the ISR and then have the main() loop check it to trigger a delay?
3.) In my limited experience with the STR9, I have found that you have to "enable" an interrupt in more than one place. For example, if you want to generate an interrupt upon the receipt of a character at the UART, then you have the set up the UART so it will assert an interrupt. This interrupt signal, in turn, must be delivered to the VIC which also must be set up to do something with the signal. I see that you have set up your VIC to handle the Ext Int pin signal, but should your code also be setting up some registers to make sure that the pin is delivering an interrupt signal to the VIC?
For whatever it is worth, you aren't the only one having trouble with interrupts on this chip. The Keil guys have been trying to sort out one of my problems for two weeks. They are very quiet...I think they are "stumped" (confounded, confused, baffled) too!
-=Rich=-
Hi Rich, Was there any resolution to this problem?
Could anyone get the external interrupts to work?
I have been trying for a couple of days to convert the STR9x WIU example (which is basically the same as the code above except that it is for the ST demo board and uses the ST library).
Your first question about "wake up" refers: do you know how the setup for plain external interrupts differs from that for a "wake up" interrupt?
William
Well, It seems you are trying to generate a external interrupt by clicking S2 (P3.5 INT5).
I dont know: 1) Where do you give VIC1 the address of your handle function (what do you want your code to do when the interruption executes?) 2) Why do you write VIC1->VCiR[10] = 0X05; instead of VIC1->VCiR[10] = 0X0A; In the reference manual, VIC1.10 is the enter for WIU group. 10 is the interrupt source for P3.5, P3.6... 3) Why do you write on WIU->PR. This must be written by hardware or using WIU->INTR to generate a software interrupt (and that's not the case)
My code is similar, but I have one problem: I cannot write on WIU->MR nor WIU->CTRL. Writing to those registers causes nothing at all. They are always clear.
Here is my code (reduced):
extern __irq void Switch_IRQ_Handler (void); /*Implemented in irq.c*/
void main(){
SCU->WKUPSEL |= 0x00000005; /*P3.5 generates interrupt*/ SCU->GPIOIN[3] |= 0xFF; /*All input. No problem at all*/
WIU->CTRL |= 0x00000002; /*WIU enabled This doesn't take effect*/ WIU->MR &= ~0x00000003; /*All unmasked. This doesn't take effect*/
GPIO3->DDR &= 0xDF; /*P3.5->input*/
/* Configure and enable IRQ for Switch S2 */ /* Debugging this doesn't shows anything wrong*/
VIC1->VAiR[10] = (unsigned int)Switch_IRQ_Handler;
VIC1->VCiR[10] |= 0x20; /* Enable vector interrupt*/
VIC1->VCiR[10] |= 10; /* Specify interrupt number*/
VIC1->INTER |= (1<<10); /*Enable interrupt*/
}
Can someone help me? What can be wrong?
OK I finally got it.
Here is the solution:
//P3 configuration
SCU->GPIOOUT[3] &= 0xC3FF; GPIO3->DDR &= 0x9F;
//WIU (AND SCU!!!) configuration //Hey, I didn't did this before!!!!
SCU->PCGR1 |= 0x00002000; SCU->PRR1 |= 0x00002000;
WIU->MR |= ~0x00000003; WIU->CTRL |= 0x00000002;
SCU->WKUPSEL |= 0x00000005;
//VIC configuration
VIC1->VAiR[10] = (unsigned int)Switch_IRQ_Handler; VIC1->VCiR[10] |= 0x20; VIC1->VCiR[10] |= 10; VIC1->INTER |= (1<<10);
And that's all to generate external interrupt by S2 (or other WIU sources).
Don't forget to acknowledge the interrupt in handler function and to clear EXTINT5 bit (WIU->PR |= 0x00000020;)
You can also work with ST librarys if you don't like to work at bit level. They got smart functions that do it for you.
Bye!