2012-07-23 01:26 PM
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 portvoid 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
2012-07-23 01:46 PM
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);
}
}
2012-07-23 01:51 PM
2013-07-01 01:46 AM
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 help2013-07-01 03:35 AM
What processor/board are we talking about? How are you configuring the pins, EXTI and NVIC?
2013-07-01 05:16 AM
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_TGPIO_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 andPowerline 2
receive it without errors. So on everyrising 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 you2013-07-01 05:18 AM
2013-07-01 07:19 AM
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?2013-07-01 07:30 AM
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.2013-07-01 08:01 AM
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.