Hi all, I am using STR912FAW44 core. I am trying to get an external interrupt from GPIO6.2 pin. There is a problem with my configuration, but I do not know where I am wrong. Could you tell me where I am wrong. My external initialization function as follows.
void externalInt_init(void) { GPIO_InitTypeDef GPIO_InitStructure; WIU_InitTypeDef WIU_InitStructure; SCU_AHBPeriphClockConfig(__VIC,ENABLE); VIC_DeInit(); SCU_APBPeriphClockConfig(__WIU, ENABLE); WIU_DeInit(); SCU_APBPeriphClockConfig(__GPIO6, ENABLE); GPIO_DeInit(GPIO6); /* GPIO6 pin configuration */ GPIO_DeInit(GPIO6); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;//|GPIO_Pin_1|GPIO_Pin_0; //GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;//GPIO_Type_OpenCollector ; GPIO_Init (GPIO6, &GPIO_InitStructure); // Enable the WIU & Clear the WIU line 18 pending bit WIU_Cmd(ENABLE ); WIU_ClearITPendingBit(WIU_Line18); //WIU_DeInit(); WIU_InitStructure.WIU_Line = WIU_Line18 ; WIU_InitStructure.WIU_TriggerEdge = /*WIU_RisingEdge;*/WIU_FallingEdge ; WIU_Init(&WIU_InitStructure); // Select WIU line 18 as VIC1.12 interrupt source SCU_WakeUpLineConfig(18); //Configure and enable the interrupt controller // VIC_DeInit(); //VIC_InitDefaultVectors(); // Configure the External interrupt group 2 priority VIC_Config(EXTIT2_ITLine, VIC_IRQ, 1); // Enable the External interrupt group 2 VIC_ITCmd(EXTIT2_ITLine, ENABLE); }
ISR as follows
void EXTIT2_IRQHandler(void) { WIU_ClearITPendingBit(WIU_Line18); printf("ext18\n"); }
Actually, since your code seems correct - I am quite sure that the above guesses represent your problem! Ho that was risky...Keep us apprised!
I controlled the SCU_PRR1 and SCU_PCGR1. the clock for GPIO6 is active and it is not held in reset. I noticed that previously I did not give enough details of the problem. When the external chip sends an interrupt, CPU goes into ISR, prints the "ext18", after that point it resets the whole system, or jumps an absurd address then it is hung on. Rougly my code as follows:
.... run() { COMMAND cmd; while(TRUE) { getCommandFromSerialPort(&cmd); switch(cmd.type) { case DO_CMD_A: sendCommandToExternalChip(cmd.data);/*it writes the data to the command register of the external chip. When the chip finishes the command it informs the cpu through the GPIO6.2 pin*/ break; ..... } } } int main() { setupSerialPort(); setupExternalChip(); externalInt_init(); run(); } ....
Always provide all relevant data! Now you forget to mention whether this happens all the time etc. How about your stack size for IRQ mode? Do you support nested interrupts? Did you check the value of LR just before leaving the ISR?
Does it still crash if you remove the "printf"?
View all questions in Keil forum