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
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.