We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi
When I use I2C library without Keil RTX to communicate with I2C EEPROM the program works fine, but when I start the RTX the program stuck at:
while(!Status) Status=I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED); // Test on EV6 and clear it
Somebody know how to fix this?
Ps: uVision3 V3.63 , MDK-ARM V3.24 , RL-ARM V3.40
I can say that I2C works well with RTX (using NXP though)
I'd suggest that you walk two steps away and try to look at the problem from a different viewpoint.
What might get changed by the presence of a RTX ? Typically interrupts. Timer usage.. ? Does that Lib need Interrupts? (I guess..) Do you see a single IRQ ? Any ports mis-set ? Are the priorities of the tasks set correctly ?
I would start with a bare OS with only one task (your program) set to a high prio and let it run. Be arware that the OS wants one timer and its interrupt. And that'S it. Nothing else. Does your task alone (without I2C code) run well?
So just try to get closer to the problem. good luck ! Uli
I lock RTOS (task_lock()) before use the I2C routines.
The I2C routines do not use interrupts, I'm using polling method.
There's just two interrupts on use (USART1_RX and USART2_RX).
I did a "bare OS with only one task" but still not working.
Ps: ARM CORTEX - M3 (STM32F103RBT6)
remove "task_lock()"...what happens?
The program stuck at I2C routine like with task_lock().
then you probably fail to configure i2c correctly. are you shutting down the hardware timer used by RTX, or something? check your RTX_Config.c file to which one is used.
Just wondering if you had fixed this problem. If you haven't, I've gotten the I2C to work on the MCBSTR9. I saw that the code is using I2C1. There are two I2Cs on the STR912. If you really want to use I2C1, then one of the I2C1 is tied to the Ethernet. You must reconfigure it via a jumper on the board. That is documented on the setup board (check the on-line manual).
Let me know if you need some help with this.
Tom
Unfortunately did not work. Im using the STM32 in the MCBSTR32. I used the I2C1 and I2C2, but both present the same problem. I created a program only to test the I2C with RTX. This program have a function that write and read 10 address of a EEPROM. In program I configured the Clocks and I2C inside main function and after I called the os_sys_init function. If I call the test function of I2C before the os_sys_init function, the function runs perfectly. But if I call the test function of I2C after the os_sys_init function (inside a task) the problem occurs.
Did you write your own I2C write/read? My routines are interrupted-based and I had to modify it from the original I2C sample. If you want, I can send you what I did. Though, I don't like to post it here because it's long.
Is it referred to I2C1 or I2C2 on your system? I thought it's STR library uses I2C0 and I2C1.
Maybe you are using STRx. In STM32 we have I2C1 and I2C2. I dont use interrupts. My code is in a Keil example too, it is polling based. Your code is for STRx or STM32 ? Can you send it to cmelo@anacom.com.br, please ? Thank you for helping.
Sure, we can take this off-line. I am using the STR91x, but unless, there's an errata on the I2Cs, I don't think it's hardware-related. Like I said, I had to modify the example.
if in a thread under RTOS, you should use a semaphore to protect your code to operate low level driver ( i2c )
?? - I am not sure what this post is all about. But anyway, in my i2c driver code, I do use a semaphore.
I am also facing problems with I2C on the STM32. I use the MCBSTM32E Board connected with the ULink2.
I canÂ't get any of the examples working that are provided by Keil or STM. (Yes I have Pullups!) Where is not even a start condition on the bus.
When I use the target SIMULATOR everything looks fine but when I use the target BOARD and debug, I can not even see the registers change when I use: I2C_Init(I2C1, &I2C_InitStructure); from the ST library.
Has anybody a working code sample for me or a hint what is wrong in my setup? All other code (CAN for example is working fine in my application)
Have you enabled the I2C clock and put it 'not in reset' state?