AnsweredAssumed Answered

Reading data from array

Question asked by delkons on May 29, 2015
Latest reply on Jun 1, 2015 by delkons
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

Outcomes