0
\$\begingroup\$

While trying to interface BMP180 to my STM32L4 Controller using libraries I found that the ,

BMP180_RETURN_FUNCTION_TYPE bmp180_get_calib_param(void)

funciton called from

BMP180_RETURN_FUNCTION_TYPE bmp180_init(struct bmp180_t *bmp180)

is unable to access the structure member through the pointer.

The BMP180_RETURN_FUNCTION_TYPE bmp180_init(struct bmp180_t *bmp180) takes the structure address and assign it to a pointer,static struct bmp180_t *p_bmp180; declared globally in bmp180.c. For Example : p_bmp180->calib_param.ac1 =(something) is not actually making any change to the structure member, whereas it changes in the init function( BMP180_RETURN_FUNCTION_TYPE bmp180_init(struct bmp180_t *bmp180)), where the address of the structure is received from bmp180_support.c.

What could be a reason for this and how to solve it? The IDE used is KeilMDK-V5.

\$\endgroup\$
0
\$\begingroup\$

The BMP180_RETURN_FUNCTION_TYPE bmp180_init(struct bmp180_t *bmp180) takes the structure address and assign it to a pointer,static struct bmp180_t *p_bmp180;

The syntax is just wrong.

\$\endgroup\$
  • \$\begingroup\$ Hi,static struct bmp180_t *p_bmp180; is the global declaration of the pointer . p_bmp180 = bmp180Add; This is how the pointer is assigned \$\endgroup\$ – Arun Joe Cheriyan Jul 12 '17 at 18:51
0
\$\begingroup\$

This happened because the the optimization level in the project options in the Keil-MDK was set to level 3, when I lowered it to level 1 ,everything worked fine; there was nothing wrong with the code.

\$\endgroup\$
  • 2
    \$\begingroup\$ If the code is correct then the optimization level should modify the behavior of the code.. So your code must be broken in some subtle way.. \$\endgroup\$ – m.Alin Jul 14 '17 at 12:51
  • \$\begingroup\$ Agreed, either undefined behaviour in the code, or a bug in the compiler. \$\endgroup\$ – pipe Jul 14 '17 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.