2015-04-20 06:50 AM
Written this code many times. No clue why it is not working. See any obvious errors?
//CODE FOR INIT. Note that APB2 clocks are initialized for portsGPIO_InitTypeDef GPIO_EXTI0;
GPIO_EXTI0.GPIO_Pin = GPIO_Pin_7; GPIO_EXTI0.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_EXTI0); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource7);
EXTI_InitTypeDef EXTI_InitStructure;
EXTI_InitStructure.EXTI_Line = EXTI_Line7; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure);NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);GPIO_InitTypeDef GPIO_InitStructure4; GPIO_InitStructure4.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure4.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure4.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOC, &GPIO_InitStructure4); GPIO_ResetBits(GPIOC, GPIO_Pin_4); //All LED control is made with 3.3V-->220R-->MCU, so pull down to turn on.//CODE FOR INTERUPT
void EXTI9_5_IRQHandler(void)
{ if(EXTI_GetITStatus(EXTI_Line7) != RESET) { /* Clear the EXTI line 0 pending bit */ EXTI_ClearITPendingBit(EXTI_Line7); if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7)) { lsb = GPIO_ReadInputData(GPIOG); msb = GPIO_ReadInputData(GPIOF) & 0b0000000001111111; msb = msb<<16; final_val = lsb | msb; clear_shift_reg(); } } }Thanks!2015-04-20 09:21 AM
GPIO Clocks enabled?
C++ Name Mangling?2015-04-20 01:50 PM
Ports are enabled. What do you mean by c++ name mangling?
2015-04-20 02:01 PM
C++ changes function names based on parameters passed and returned.
EXTI9_5_IRQHandler might be something else from the linker's perspective, and not bind to the vector table in the manner you had hoped.http://en.wikipedia.org/wiki/Name_mangling
extern ''C'' void EXTI9_5_IRQHandler(void){}Not much of a C++ guy myself, but you use declarations mid function.