2012-11-11 09:12 AM
Is there an inherent reason why activating EXTI0 using PA0 would interfere with a previously functioning I2C1 transmission operation? (Atollic TrueStudion Lite)
That is, I tried to add ext interrupt from previous project, to a newer one studying I2c. The I2C functions(sends char to Arduino slave which sends to serial monitor for me) alone, but when I add the setup for the EXTI0(no build errors), the original I2C transmission stops. When I comment out the EXTI0 configuration, the I2C resumes functioning.Also: when I comment out the I2C, then the external interrup works. #isr #stm32f4discovery-i2c-exti02012-11-11 01:19 PM
I'm not aware of any intrinsic issues, have you reviewed the errata?
What pins are you using for I2C? and how are you configuring the EXTI?2012-11-14 02:57 PM
Clive,
I2C on PB6,7 with the STM32F407Discovery as Master transmitter. This works fine as long as the EXTI0 is commented out. I've attached my associated source files for I2C and EXTI0 (I hesitate to dump this on you), and from main.c I have handler to just send 'Z' via I2C to my Arduino-->Serial monitor. This works fine as long as the I2C is commented out.void
EXTI0_IRQHandler(
void
)// stm32f4xx_it.c has this and includes LED4 if you need it...I just put it here manually
{
if
(EXTI_GetITStatus(EXTI_Line0) !=
RESET
)
{
I2C_start(I2C1, SLAVE_ADDRESS, I2C_Direction_Transmitter);
I2C_write(I2C1,
'Z'
);I2C_stop(I2C1);
EXTI_ClearITPendingBit(EXTI_Line0);
}
}
________________ Attachments : myEXTI0.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzjq&d=%2Fa%2F0X0000000bOr%2F.TK_I01xZ_vR.XmkAVRkFLTjvCBgFyilmyhqKxFxf8k&asPdf=falsemyI2C1.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzjl&d=%2Fa%2F0X0000000bOp%2FR86wD.tYb2aCxOM7FE7ka_ZaD8I_d8oU2HLTBK04Rzk&asPdf=false2012-11-14 11:37 PM
Probably not a good idea to be running the I2C comms from inside the EXTI ISR - or any ISR, for that matter...
2012-11-15 03:29 AM
Nothing is jumping out with a quick walk of the code, although as Andrew has noted doing this kind of looping under interrupt probably isn't something we'd do.
From a trouble-shooting perspective, I think I'd use the debugger or LED and confirm it's entering and/or exiting the IRQ handler. Then I'd go look and see which while() loop it's hanging up in, and why.2012-11-15 07:42 AM
Clive,
Actually, LED blink also no good inside IRQ, as long as I2C is active.2012-11-15 07:47 AM
Andrew,
Yes, it's been suggested I use RTOS. In fact I have FreeRTOS within Eclipse/TrueStudioLite, but do not yet understand it. Both Clive and a buddy of mine have suggested some clocking issue in the conflict between I2C and EXTI. I was hoping to learn by finding a workaround, such as Clock Stretching with which I have had no experience yet. You see, RTOS seems well beyond my current hobby needs and I would like to learn all I can at simpler level, if that's practical........I can't make head nor tail out of the RTOS source files. In fact the demo is the LED gyroscope thing(LED on towards the 'high' side of Board when you tilt it) but for the life of me I can't find any GPIO coding in the FreeRTOS files yet to explain how that RTOS implements the code.2012-11-15 08:00 AM
By the way, USART1 works fine inside EXTI0 ISR...