2014-02-05 10:49 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 you2014-02-05 11:48 PM
If the ''ISR RESPONSE'' trace is produced by two consecutive writes to GPIO
GPIOC->BSRRL = GPIO_Pin_9; GPIOC->BSRRH = GPIO_Pin_9; then you are probably not running the processor at 168MHz. JW2014-02-06 07:00 AM
4 MHz is a bit excessive! Try 40 KHz or 400 KHz first.