TWI Module problems

Hi there
I am facing a strange issue nowadays after working continuously for two weeks + with the TWI module. I started off the with twi_sensor example in non blocking but "polling" mode.

By polling mode I mean the xfer flag was continuously being read in while();  I replicated that and it worked. What I added to that is instead of reading a static global flag. I read the flag status via a function and then proceed to immediately go for a write after read.

So the flow is like this:

Write ---> Wait for while(  ret =  getStatus()  == true ); polling---> Immediately read
This gives me ambiguous results until I add an nrf_delay immediately after the read. The write is not done properly, infact its not done at all in most cases. I ensured that as I know that the read function is working absolutely correctly.

So Q1 is
Why should I need a delay when the event has been fired, what good will the nrf_delay is after the write? Please explain, the example project with a global flag works fine, same thing with a

small function call doesnt

I managed to fix it with multiple function calls but return calls
so my function calls were:
write_api(pass data) --->eeprom_write(pass_data)--->nrf_xfer

So after the transfer is done the function returns two times, by that time the transfer is always complete (without delay)

Anyways Q2 is:
2) Debug vs Release - The above scenario only works in Debug mode, why not in Release mode?

I need to fix this within a week,our product is in dev phase and since its working in debug mode we have moved forward, but we will eventually need to fix it

Parents Reply Children
Related