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
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.
Hi cleber melo,
The problem I think you was facing was that you did not kill the current running thread inside the init() function.
If you do not kill the current running thread, it will return to the startup code thus terminates the whole program.
Here is what you should do:
void init(void) { // Initialize code is here // ... // Kill the current running thread os_tsk_delete_self(); } void main(void) { os_sys_init(init); }
First of all,thanks you all for help. This is not the problem, my init function call the self kill procedure. All the RTX are working. My code have only one task, and inside it I call a test function that write 10 address at EEPROM and read the same address after.
Reading the datasheet, I saw a bit that reset the I2C thru sowftware (bit 15 of CR1 of STM32F103RB). Setting this bit force the I2C to go to reset state, cleaning it put the I2C in ready state. So I tried to reset and reconfigure the I2C before every write/read action, and it works. The problem was solved thought I ! But how not everything is a sea of roses, I dont know why the interrupt of USART stopped work. So the problem still unsolved.
Perhaps now you would like to resort to keil debugger to find out why the UART is not working properly. I suggest that you check all the register states of the peripheral. Go to the menu bar, click on the 'Peripheral' and then 'UART'. You might want to check the VIC as well.
This was the first thing that I did. And the strange is that all the registers still correctly set.
Does your code clear the appropriate interrupt flag(s) in the ISR? properly acknowledge the VIC in the ISR? Also it is advisable to clear appropriate interrupt flag(s) during device initialization (this is to allow generation of first interrupt.)
I dont use interrupts. Im polling the I2C.