This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Equation result is not as expected

Hello,

there is an equation in the code where I see that variable: deviceid is: 229 and var_temp is also: 229.

But the debugging shows that the Mikrocontroller is going into this if-case. I cant understand why. Both variables are uint8_t and have the same value.

  • I am using Segger-Embedded-Studio V3.30.
  • I am using SEGGER EDU
  • I am using NRF52832

I have downloaded the code into Mikrocontroller several times. So I am shure that the code in the mikrocontroller is the same code as I see in the Embedded-Studio IDE.

if (deviceid != var_temp)
{
  ret_eok |= ERROR_BIT_0;
}

Do you have any ideas what is going wrong?

Parents
  • Yes its very strange.

    I am reading the DeviceID from an accelerator sensor. I tried several solutions (equation with uint8_t variable, with Makro, with hexvalue). Nothing is working. CPU is going always in this if case.

    In Segger IDE it says that deviceid is the same value (0x33) as the Makro or other variable.

      uint8_t deviceid = 0;
    
        // read device ID
            if ((nrf52810_drv_twim0_rx_data((uint8_t) LIS3DH_I2C_DEVICE_ADDRESS, (uint8_t) WHO_AM_I, &deviceid, sizeof(deviceid))) != 0)
            {
               return_eok |= ERROR_BIT_0;
            }
                
            if (return_eok == 0)
            {
               if (deviceid != LIS3DH_VALUE_DEVID)
               {
                  return_eok |= ERROR_BIT_1;
               }
            }
    

    Maybe there is something wrong with Compiler Settings or something like this. Its like I see in Segger IDE not the same what the Mikrocontroller gets from the compiler (as assembler code).

  • No. I am not working with the official SDK Board. I have built my own Prototype/Evaluation Board. So I am going to check the SDK examples configruation.

    What I did: I took the default configuration for the NRF52832 in the Segger Studio IDE.

    What I discovered is that it doesnt matter which value I give this equation. Its always true. So its like the Mikrocontroller doesnt get this right value for the equation.

Reply
  • No. I am not working with the official SDK Board. I have built my own Prototype/Evaluation Board. So I am going to check the SDK examples configruation.

    What I did: I took the default configuration for the NRF52832 in the Segger Studio IDE.

    What I discovered is that it doesnt matter which value I give this equation. Its always true. So its like the Mikrocontroller doesnt get this right value for the equation.

Children
No Data
Related