This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't read or write any TWI registers after moving to the app_twi library

Hi there,

In the process of moving from SDK 10 to SDK 11, I've also been migrating an accelerometer driver over from using straight nrf_drv_twi code to the higher level app_twi library. The driver has stopped working completely.

Although I can read from and write to registers without app_twi_perform() returning an error, the values read back are always zero and the values I write have no effect.

I was initially caught out by the fact I needed to set pin numbers both in the call to APP_TWI_INIT() and in my nrf_drv_config.h file, but that is now fixed.

I am right shifting the slave address to remove the R/W bit from it.

My max transactions define is 20 and I don't put that many transfers through.

Is it OK that my app_twi_transfer_t variables are NOT static? I read somewhere in the SDK code that they should be if I'm scheduling these up, but I only ever call app_twi_perform() and never app_twi_schedule().

[Edit]

After Ole's comment below, I've made all the transfers and register value variables static. It hasn't fixed the issue - I'm still seeing all zeros for all the registers I read back.

New code attached.

acc_kionix_ktxj2.h

acc_kionix_ktxj2.c

Parents Reply Children
No Data
Related