STM32L476 (Disco)

Hi Rink,

The buffer should contain 600 values. If only 3 are filled that would explain the same results as mentioned by Jan.

Aurelien

1 Like

sir , actually the buffer have 600 values , but just print first three value for showing variation .

void lis2dw12_read_data_single(void)
{
stmdev_ctx_t dev_ctx;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;

platform_delay(BOOT_TIME);
lis2dw12_device_id_get(&dev_ctx, &whoamI);
if (whoamI != LIS2DW12_ID)
{
printf(“Device not respond\r\n”);
}

lis2dw12_reset_set(&dev_ctx, PROPERTY_ENABLE);
do
{
lis2dw12_reset_get(&dev_ctx, &rst);
} while (rst);

lis2dw12_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);

lis2dw12_int_notification_set(&dev_ctx, LIS2DW12_INT_LATCHED);
lis2dw12_pin_polarity_set(&dev_ctx, LIS2DW12_ACTIVE_LOW);

lis2dw12_pin_int1_route_get(&dev_ctx, &ctrl4_int1_pad);
ctrl4_int1_pad.int1_drdy = PROPERTY_ENABLE;
lis2dw12_pin_int1_route_set(&dev_ctx, &ctrl4_int1_pad);

lis2dw12_full_scale_set(&dev_ctx, LIS2DW12_2g);

lis2dw12_filter_path_set(&dev_ctx, LIS2DW12_LPF_ON_OUT);
lis2dw12_filter_bandwidth_set(&dev_ctx, LIS2DW12_ODR_DIV_10);

lis2dw12_power_mode_set(&dev_ctx, LIS2DW12_CONT_LOW_PWR_12bit);
lis2dw12_data_rate_set(&dev_ctx, LIS2DW12_XL_SET_SW_TRIG);

memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
lis2dw12_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
acceleration_mg[0] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[0]);
acceleration_mg[1] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[1]);
acceleration_mg[2] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[2]);

lis2dw12_data_rate_set(&dev_ctx, LIS2DW12_XL_SET_SW_TRIG);
for(int i =0 ; i< 600 ; )
{
features[i++] = acceleration_mg[0];
features[i++] = acceleration_mg[1];
features[i++] = acceleration_mg[2];
HAL_Delay(10);
}
/* sprintf((char *)p_buf,"%f %f %f \r\n",features[0],features[1],features[2]);
HAL_UART_Transmit(&huart2, (uint8_t )p_buf, sizeof(p_buf),1000);/
}

this is my sensor code , you can see I
fill my features buffer with 600 data values

Hi @Rink,

You’re not reading from the accelerometer in the loop. You should call lis2dw12_acceleration_raw_get every time to get the new values. Now you’re writing the same value over and over.

see it is inside my int main() function , I put my in while(1) so every time they get updated value even i also checked it

@Rink, it is not:

memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
lis2dw12_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
acceleration_mg[0] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[0]);
acceleration_mg[1] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[1]);
acceleration_mg[2] = lis2dw12_from_fs2_lp1_to_mg(data_raw_acceleration[2]);

lis2dw12_data_rate_set(&dev_ctx, LIS2DW12_XL_SET_SW_TRIG);
for(int i =0 ; i< 600 ; )
{
// SHOULD READ FROM ACCELEROMETER HERE

features[i++] = acceleration_mg[0];
features[i++] = acceleration_mg[1];
features[i++] = acceleration_mg[2];
HAL_Delay(10);
}

Here you read the accelerometer once and then keep writing those same values. You should update the acceleration_mg array every time you hit this loop.

1 Like

hey @janjongboom thanks a lot for helpping me …finally it works … I realize my mistakes
You are right …every time fill same x,y,z data in buffer , I had small change in my code and then it works :slight_smile: :smiley:

2 Likes

@Rink, great! Glad to be able to help!

1 Like

Hello sir ,
How can i link all the library(stranded cpp) components (folders) with CMakeList.txt file , can you give me some direction something , I am Working on nrf52840 with Zephyr , and programming with linux terminal.

Hey @Rink, add a CMake rule that finds all .h, .cc, .c, and .cpp files, and then exclude the edge-impulse-sdk/porting, utensor and ei_run_classifier_c.* files. See:

For an example.

Hello Sir,
as you say ,
CMake rule that finds all .h , .cc , .c , and .cpp files, and then exclude the edge-impulse-sdk/porting , utensor and ei_run_classifier_c.* files.
I done it , after this I build my code but there are so many errors .
And porting folder file error also ,
so give me some solution , I am working on nrf52840 Dk board , and conding in zephyr os

I was not change any files or folder in your standard sdk just deleting porting , utensor and ei_run_classifier_c.* nothing else .

@Rink here’s an end-to-end example with a Zephyr project: https://docs.edgeimpulse.com/docs/running-your-impulse-locally-zephyr

1 Like

thanks a lot sir its works well …

1 Like