Skip to main content
delkons
Associate
May 28, 2015
Question

Reading data from array

  • May 28, 2015
  • 1 reply
  • 903 views
Posted on May 29, 2015 at 00:03

Hi,

I'm developing application which include I2C communication, so I have implemented code from AN8231.

So far it works fine and I got data from I2C peripheral in input_buf[]. Data are valid, and I can see them in watch window in the debugger session. But when I try to use data ie:

Raw_X_L = input_buf[0];

it is always 0x00  which is not valid value (from watch window).

Here is code:

u8 input_buf[MAX_INPUT];    //receiving buffer

u8 output_buf[MAX_OUTPUT]; //transmitting buffer

...

...

void Read_M (void)

{

    output_buf[0] = (OUT_X_L_M | 0x80);

    while (!I2C_WriteRegister(lsm9ds0_xm_addr,SEV_BIT_ADDRESS, STOP, 0x01, &output_buf[0]));

    while (!I2C_ReadRegister(lsm9ds0_xm_addr, SEV_BIT_ADDRESS, STOP, 0x06, &input_buf[0]));

}

...

...

Raw_X_L = input_buf[0];

How to assign data from input_buf[] to variable? At the same time I can assign value from output_buf[].

Compiler is COSMIC STM8

Best regards,

Vojislav

    This topic has been closed for replies.

    1 reply

    delkons
    delkonsAuthor
    Associate
    June 1, 2015
    Posted on June 01, 2015 at 21:46

    Solved!