Hello!
I'm using SDK 12.3.0 with nRF51822. Unfortunately since the begining I've got a problem with TWI interface. It keeps crushing my app. For no reason. At the beginning I was using a FreeRTOS. I did assume that RTOS with TWI steals so much processig power from SD(s130) that it just gives up. So i switched to simple scheduler(one provided with SDK12). Unfortunatley it didn't solve my problem. At this point I should describe "crushing". I'm using TWI to transfer 2 bytes of data (plus address ofcourse) every 8ms with interrupts. Transactions are fired in app_timer(scheduler implementation - I assume that timer handler works in main context). I've tried to use both bare driver and library wrapper(app_twi). My problem is that procesor just stops. I can't catch any debug info(using RTT), hardware debugging(gdb) gives no answer. He just dies on me. And it is absolutley non deterministic. BUT! I've noticed something:
switch (app_twi_schedule(&m_curren_state.nrf_drv_instance, &_transaction)){
case NRF_SUCCESS:
m_curren_state.callback = callback;
int _to = 200;
while(_to--)
__NOP();
/*printf("{%lu}hello!\n", app_timer_cnt_get());*/
return IC_SUCCESS;
case NRF_ERROR_BUSY:
return IC_BUSY;
default:
return IC_ERROR;
}
Please notice the while(_to--) __NOP();
. For some bizarre reason this fixes my probem (without, processor manages to die in 0-1s. I'm running it for a hour now, and it didn't die yet). Also, debug info seems to extend "not crushed" state but still at some point processor dies. Provided code seems to work.
For me, there it is timing issue. I'm doing something too long or too quickly. But kill me... I have no idea what I did wrong. I hope you could drop me some hint.
Paweł K.