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

NRF52832 - ADT7410 TWI Communication

Hello,

I want to discuss the following code with you:

www.dropbox.com/.../AABddGcZagoqWHnJqfPrpbm9a

In the main file there are init functions for uart and twi and also get_temperature function for adt7410. I used app_uart_put as debug function. For example at the line at the line 74

app_uart_put('1');

shows the twi_init is successful.

What I want to discuss is at the terminal, I only see 1 as output. adt7410 (twi sensor) related functions does not give any output. What can be the reason?

Thanks all of you take a look at a code!!!

  • You say you only see the 1 outputted from line 74? You should also see something from line 87. The app_uart_put() function has a 32 bit return value, have you checked if it produces an error?

  • Yeah, it should also be an output, just as you said. It compiles without an error, so I opened this question to discuss possible reasons

  • The error value is not generated on compile, but on execution. If the app_uart_put function, on execution, isn't executed properly there are checks within the code that will assign it an error code. Typically you would write code that returns an error code as

    err_code = app_uart_put();
    APP_ERROR_CHECK(err_code);
    

    In this case an error handler will be called if the app_uart_put function is not successfully executed. If you set the DEBUG flag within the preprocessor symbols, all errors should put your program in a loop, in which you can try and determine the cause of your error when using debugging.

    If the function is executed properly the return value will be 0, which is defined as NRF_SUCCESS.