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 dont use interrupts. Im polling the I2C.
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.)
This was the first thing that I did. And the strange is that all the registers still correctly set.
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.
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.
good hint, thanks. the clock was not enabled
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); }
Have you enabled the I2C clock and put it 'not in reset' state?
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)
?? - I am not sure what this post is all about. But anyway, in my i2c driver code, I do use a semaphore.
if in a thread under RTOS, you should use a semaphore to protect your code to operate low level driver ( i2c )
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.
Tom
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.
Is it referred to I2C1 or I2C2 on your system? I thought it's STR library uses I2C0 and I2C1.
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.
View all questions in Keil forum