cancel
Showing results for 
Search instead for 
Did you mean: 

Blue Pill external interruption

wojtek s
Associate
Posted on August 26, 2017 at 02:37

Hi,

recently I started my adventure with STM32F103C8T6. I had some experience with programming on other boards e.g STM32F3 Discovery but I came accross a problem with external interruptions. I am using EclipseStm as IDE, where my trouble making board was not defined as default (I have to do it myself). I have to point out that I did some research and i did not found any solution.

Also, I have to point out that I have no problems with other interruptions e.g TIMx and SysClock on this board.

Basing on my knowledge from Discovery board I have created this simple code:

&sharpinclude <stdbool.h>

&sharpinclude 'stm32f10x.h'

&sharpdefine DIOD GPIO_Pin_3

&sharpdefine INT GPIO_Pin_11

&sharpdefine INT_SRC GPIO_PinSource11

void init() {

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);

    //initializing blinking diod

    GPIO_InitTypeDef GPIOinit;

    GPIOinit.GPIO_Pin = DIOD;

    GPIOinit.GPIO_Mode = GPIO_Mode_Out_PP;

    GPIOinit.GPIO_Speed = GPIO_Speed_2MHz;

    GPIO_Init(GPIOA, &GPIOinit);

    //initializing input pin

    GPIOinit.GPIO_Pin = INT;

    GPIOinit.GPIO_Mode = GPIO_Mode_IN_FLOATING;

    GPIO_Init(GPIOB, &GPIOinit);

   

    //initializing exti

    GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, INT_SRC);

    EXTI_InitTypeDef EXTIinit;

    EXTIinit.EXTI_Line = EXTI_Line11;

    EXTIinit.EXTI_LineCmd = ENABLE;

    EXTIinit.EXTI_Mode = EXTI_Mode_Interrupt;

    EXTIinit.EXTI_Trigger = EXTI_Trigger_Rising_Falling;

    EXTI_Init(&EXTIinit);

    //initializing handler

    NVIC_EnableIRQ(EXTI15_10_IRQn);

    NVIC_SetPriorityGrouping(NVIC_PriorityGroup_2);

    NVIC_InitTypeDef NVICinit;

    NVICinit.NVIC_IRQChannel = EXTI15_10_IRQn;

    NVICinit.NVIC_IRQChannelCmd = ENABLE;

    NVICinit.NVIC_IRQChannelPreemptionPriority=2;

    NVICinit.NVIC_IRQChannelSubPriority=2;

    NVIC_Init(&NVICinit);

}

void EXTI15_10_IRQHandler() {

    static bool flag = false;

    if(EXTI_GetITStatus(INT_SRC) != RESET) {

        flag ? GPIO_SetBits(GPIOC, DIOD) : GPIO_ResetBits(GPIOC, DIOD);

        flag = !flag;

    }

    EXTI_ClearITPendingBit(INT_SRC);

}

int main(void)

{

    init();

    while(1);

}

I have figured out that (in my case) there is no EXTI15_10_IRQHandler function call. I cannot find even its declaration while searching peripherial library files (in F3 board there is occurence).My question is there something wrong with my library that I do not have some functions? Or Maybe I am doing something wront with initialization? Can someone explain this strange behavoir?

#interrupts #stm32f103c8t6
0 REPLIES 0