Hi,
I am using the STR912FA44 and I am trying to use two external interrupts of the same port but for some reason it doesn't work. Both interrupts work properly when used separated but when used together it just doesn't work, I don't get any interrupt anymore. The interrupt lines are WIU_Line8 and WIU_Line9 that correspond to the Port5 pin 0 and pin 1. This is my code:
Port/pin declaration: // GPIO 5 SCU_APBPeriphClockConfig(__GPIO5, ENABLE); SCU_APBPeriphReset(__GPIO5, DISABLE); GPIO_DeInit(GPIO5); // SJA1000 Chip Interrupts GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1; // INT_1, INT_2 // lines 8 and 9 GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_Init (GPIO5, &GPIO_InitStructure); Interrupt Initialization: WIU_Cmd(ENABLE ); WIU_ClearITPendingBit(WIU_Line8); // EXT Group 1 Port 5.0 -> INT_CAN1 WIU_ClearITPendingBit(WIU_Line9); // EXT Group 1 Port 5.1 -> INT_CAN2 WIU_StructInit(&WIU_InitStructure); WIU_InitStructure.WIU_Line = WIU_Line8|WIU_Line9; WIU_InitStructure.WIU_TriggerEdge = WIU_FallingEdge ; WIU_Init(&WIU_InitStructure); SCU_WakeUpLineConfig(9); SCU_WakeUpLineConfig(8); /* Configure the External interrupt group 1 priority as IRQ interrupt */ VIC_Config(EXTIT1_ITLine, VIC_IRQ, 6); /* Enable the External interrupt group 1 */ VIC_ITCmd(EXTIT1_ITLine, ENABLE);
In case that in not possible to use two wake up lines in the same port, what is the alternative besides using different ports? Thanks for your help!
Milton
Thanks for your answer I did exacly that yesterday, but I still have a problem: So my declaration for the int VIC1.9:
WIU_Cmd(ENABLE ); WIU_ClearITPendingBit(WIU_Line8); // EXT Group 1 Port 5.0 -> INT_CAN1 WIU_ClearITPendingBit(WIU_Line9); // EXT Group 1 Port 5.1 -> INT_CAN2 WIU_StructInit(&WIU_InitStructure); WIU_InitStructure.WIU_Line = WIU_Line8|WIU_Line9; WIU_InitStructure.WIU_TriggerEdge = WIU_FallingEdge ; WIU_Init(&WIU_InitStructure); VIC_Config(WIU_ITLine, VIC_IRQ, 6); VIC_ITCmd(WIU_ITLine, ENABLE);
and the WIU_IRQHandler:
void WIU_IRQHandler(void) { vu32 a=0; a= VIC1->VAR; if (WIU_GetITStatus(WIU_Line8)==SET) { printf ("\r\n Line 8 interrupt"); ExtInt1Handler(1); WIU_ClearITPendingBit(WIU_Line8); } if (WIU_GetITStatus(WIU_Line9)==SET) { printf ("\r\n Line 9 interrupt"); ExtInt1Handler(2); WIU_ClearITPendingBit(WIU_Line9); } /*write any value to VIC1 VAR*/ VIC1->VAR = 0xFF; }
My problem is that I am rising the interrupt 8 and 9 at aprox the same time and for some reason I just get an answer always one of the lines, either one or the other. How can I make sure that I "process" both interrupts once I am inside the handler? Is it because I am using this in the handler, and the priorities are updated before the entry of the second one?
vu32 a=0; a= VIC1->VAR; .... VIC1->VAR = 0xFF;
Thanks for your help.
How can I make sure that I "process" both interrupts once I am inside the handler?
check in the VIC if there is a pending interrupt?
uhh ... sorry, how do I do that?
Thanks
I think that you can use the VICx_RINTSR register for that - have a look at the STR9 user manual to be sure.
I'm not fond of printf() in an interrupt handler. It may work, but may just as well fool you into thinking things that aren't true.
It is better to use a couple of LED for different states and use a scope to look at the LEDs two at a time - or four at a time if you have a nicer scope than I have :)
Thanks for your answer guys. So I did like Tamir said, I check VIC1->RINTSR and while is 0x2000000 (WIU_ITLine) I do the check. I happens that this value is always 0x00000A00 which is USBLP_ITLine and ENET_ITLine (none of the modules are active)??? Something else, if I use only one line it works ok ... but only for 128 interrupts afterward a Abort interrupt is raised?!?!?!?!? Thanks Per for the tip, you are right, printf's there is not a good idea. But I have the same strange results without them.
void WIU_IRQHandler(void) { vu32 a=0; vu32 b=0; a= VIC1->VAR; b=VIC1->RINTSR; while ( VIC1->RINTSR==0x2000000) { if (WIU_GetITStatus(WIU_Line8)==SET) { SetLedColor(0,5); ExtInt1Handler(1); WIU_ClearITPendingBit(WIU_Line8); } if (WIU_GetITStatus(WIU_Line9)==SET) { SetLedColor(1,5); ExtInt1Handler(2); WIU_ClearITPendingBit(WIU_Line9); } } /*write any value to VIC1 VAR*/ VIC1->VAR = 0xFF; }
I think I know where is the problem, in the pin definition I have:
GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable
and should be enabled ...
The problem is when I enable my firmware blocks!? Just like that, there is not pin conflict or nothing. After reading a bit about it I think it comes from spurious Interrupts. Does anyone know how to deal with this, is there some workaround?
Thanks guys!