2014-02-05 10:46 PM
I wrote a code to generate rising edge interrupts for a 4MHz clock input to the board. The 4MHz input is generated by MCO while the core is pushed to 168MHz.
I found that certain interrupts are not being tacked at all and when they are tackled, there are delays often (but not always) for the Microcontroller to enter ISR.I am simply toggling external pin in the ISRMAIN.C__________________________________________________________int main(void){ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_Pin_8, GPIO_AF_MCO); RCC_MCO1Config(RCC_MCO1Source_HSE,RCC_MCO1Div_2); EXTILine1_Config( ); while (1);}void MCO_CLK_CONFIG(void){ RCC_HSEConfig(RCC_HSE_ON); while(!RCC_WaitForHSEStartUp()) { }}void EXTILine1_Config(void){ /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOA, &GPIO_InitStructure); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource1); EXTI_InitStructure.EXTI_Line = EXTI_Line1; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);}ISR________________________________________________________________________________________________ISRvoid EXTI1_IRQHandler(void){ if(EXTI_GetITStatus(EXTI_Line1) != RESET) { GPIOC->BSRRL = GPIO_Pin_9; GPIOC->BSRRH = GPIO_Pin_9; EXTI_ClearITPendingBit(EXTI_Line1);}}Following is the image on Logic analyzer we captured.Can someone enlighten me regarding what the issue can be?Thank you #stm32f4-discovery-interrupt2014-02-06 05:15 AM
I wonder how many cycles it takes for stm32f4 to go into an interrupt and toggle a pin. Perhaps more than 168/4 cycles? Anyone?
Regards,rygelxvi2014-02-06 12:00 PM
Interrupt latency is typically about 12 clock cycles for a Cortex-M4 CPU (best case), assuming that the memories involved can operate with 0 wait states.
The pulse you are attempting to generate in the ISR should be about 6 ns wide. Is your analyzer able to capture signals that short? Incidentally, it's doubtful that the GPIO pins can even operate at that speed.