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.
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!