cancel
Showing results for 
Search instead for 
Did you mean: 

GPIOB_pin12 connecting to interrupt line

linas2
Associate II
Posted on July 23, 2012 at 22:26

hello, i am trying to make interrupt based touchscreen program, but have no luck connecting

GPIOB_pin12 to interrupt line i was able to do so in GPIOA_pin1, but still cant figureout how to do that on GPIOB port

void touch_init(void)
{ 
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource12);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB);
//T_PEN
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOB, &GPIO_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line12;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; 
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
and interrupt itself in stm32f4_it.c file:
void EXTI4_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line12) != RESET)
{
LCD_Clear(RED);
Delay(0xFFFFFF);
EXTI_ClearITPendingBit(EXTI_Line12);
}
}

i should get interrupt on falling edge, when i touch touchscreen Pen_IRQ (PORTB leg 12) goes low, i double-checked that
12 REPLIES 12
Posted on July 23, 2012 at 22:46

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB); //T_PEN
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource12);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOB, &GPIO_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line12;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; 
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; // ie 12 is between 10 and 15
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line12) != RESET)
{
LCD_Clear(RED);
Delay(0xFFFFFF);
EXTI_ClearITPendingBit(EXTI_Line12);
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
linas2
Associate II
Posted on July 23, 2012 at 22:51

Thank you sir, that worked brilliantly .

elazhar
Associate II
Posted on July 01, 2013 at 10:46

Hi ,

Im using EXTI9_5_IRQHandler  because i trig on PA8 & PA5 and i want to send a msg if PA5 is ON and receive it  if PA8 is ON.

I dont know how to implement this and to set the priority because i m using EXTI9_5_IRQn :

I tried to do something like this but it didn't work

void EXTI9_5_IRQHandler(void) {

        CPL1_data_transmit();

        EXTI_ClearITPendingBit(EXTI_Line5 );

    }

    if (EXTI_GetITStatus(EXTI_Line8 ) != RESET) {

        CPL2_data_receive();

        EXTI_ClearITPendingBit(EXTI_Line8 );

    }

}

Please help

Posted on July 01, 2013 at 12:35

What processor/board are we talking about? How are you configuring the pins, EXTI and NVIC?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
elazhar
Associate II
Posted on July 01, 2013 at 14:16

Im using STM32VLDISCOVERY to establish communication (SPI)between 2 EVLAST7540 ( PLC EVAL BOARD) . So PA8 & PA5 are clock signal that the 2 EVALST7540 provide

respectively

. pins are configured as following :

   GPIO_InitStructure.GPIO_Pin = PIN_SCK2;  // PA5

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

    GPIO_Init(PORT_SCK2, &GPIO_InitStructure); //SCK / CLR_T

   GPIO_InitStructure.GPIO_Pin = PIN_SCK1;  // PA8

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

    GPIO_Init(PORT_SCK2, &GPIO_InitStructure); //SCK / CLR_T

What i want to do is to transmit data from Powerline 1 to Powerline 2 and

Powerline 2

receive it without errors. So on every

rising edge

of PA5 (clk1) I SEND a bit .

The problem is im using PA5 and PA8 that are  between 5 & 9 so i must use EXTI5_9IRQn so i can't configure priority fo each Pin if i want  Powerline 1 to start communication ...

I hope i was clear . Sorry for my english

Thank you

elazhar
Associate II
Posted on July 01, 2013 at 14:18

Code of EXTI & NVIC

void EXTI5_config(void) {

    /* Enable AFIO clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    /* Enable GPIOA clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    /* Enable GPIOC clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

    NVIC_InitTypeDef NVIC_InitStructure;

    // Interrupt test

    /* connecting GPIOA with EXTI5 */

    GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource5 );

    EXTI_InitTypeDef EXTI_InitStructure;

    EXTI_InitStructure.EXTI_Line = EXTI_Line5;

    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

    EXTI_InitStructure.EXTI_LineCmd = ENABLE;

    EXTI_Init(&EXTI_InitStructure);

    //disable AFIO clock

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, DISABLE);

    /*4 bits for preemp priority 0 bit for sub priority*/

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0 );

    /* Set exti0 interrupt at the lowet priority*/

    NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

}

/*

 * Interrupt on Rising Edge of CLR/T for SPI communication ( CPL2 part)

 */

void EXTI8_config(void) {

    /* Enable AFIO clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    /* Enable GPIOA clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    /* Enable GPIOC clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

    NVIC_InitTypeDef NVIC_InitStructure;

    // Interrupt test

    /* connecting GPIOA with EXTI8 */

    GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource8 );

    EXTI_InitTypeDef EXTI_InitStructure;

    EXTI_InitStructure.EXTI_Line = EXTI_Line8;

    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

    EXTI_InitStructure.EXTI_LineCmd = ENABLE;

    EXTI_Init(&EXTI_InitStructure);

    //disable AFIO clock

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, DISABLE);

    /*4 bits for preemp priority 0 bit for sub priority*/

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0 );

    /* Set exti0 interrupt at the lowet priority*/

    NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    //Subpriority définit qui s’exécutera en premier si deux interruptions du

    //même group priority arrivent en même temps

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

}

Posted on July 01, 2013 at 16:19

You are right, you're not going to give the pins different priorities, but I am honestly not sure why that would make a difference.

I guess I'm trying to understand why you need to use EXTI interrupts, and whether some SPI or USART interface isn't more appropriate?

What is the bit rate you are hoping to achieve?

You are also using C++ syntax, be certain that your IRQHandler is correctly named and linked via the vector table. Check the vector table. Are you receiving interrupts?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
elazhar
Associate II
Posted on July 01, 2013 at 16:30

In this case , i will receive both interrupts at the same time even if i call EXTI5_config() function before EXTI8_config(void) in the main??

I dont use SPI because the EVALST7540 's SPI is weid a little bit , it didn't has a Chip Select .

I checked the link to the vector table , it's working because i already tested Write and Read functions using EXTI5 for communication between CPL1 and STM32VLDISCOVERY.

Posted on July 01, 2013 at 17:01

In this case , i will receive both interrupts at the same time even if i call EXTI5_config() function before EXTI8_config(void) in the main??

 

Correct, you're basically replicating some of the configuration, and doing it twice or in a different order won't material change that.

You can choose the order in which you inspect/service the EXTI once they arrive. You're not going to be able to separate events that occur a couple of 100ns apart in software. You could use a TIM in Input Capture mode to time stamp events on a common time line, and separate them that way.

Ok, so the vector/interrupt is working.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..