cancel
Showing results for 
Search instead for 
Did you mean: 

LPBAM I2C data buffer using NUCLEO-U575ZI-Q

IlariaCrupi
Associate II

Hi everyone, 

I am trying to use LPTIM1 and I2C3 to read the values of a sensor's register every 1 second and save them into a data buffer while in Stop2 mode. What I would like to know is if it is possible to store data sampled at a given frequency in a data buffer, thus incrementing the offset value at each I2C transaction, without needing to add multiple I2C Receive boxes in the Queue. I would like to perform everything while in Stop2 mode and to wake up the uC only when the data buffer is completely filled with data. 

I performed 3 tests using the NUCLEO-U575ZI-Q board, each of them is provided below as .rar files.

 

1st TEST (Test_00.rar in the attached files):

In the "Pinout & Configuration" view, I configured the LPDMA1 Channels 0 and 1 in Linked-List mode, enabled both LPDMA1 SmartRun Channel 0 and 1 global interrupts, and set CH0 and CH1 Execution Modes as Linear. 

In the "LPBAM Scenario & Configuration" view, I configured the following peripherals: 

  •  LPTIM1 in "Counts internal clock events" mode, enabling Channel_1 _Active and setting the Pulse Period and Pulse Value to generate a PWM signal with a 1000 ms period and 50% duty cycle. LPTIM1 will be used as a trigger source for I2C communication so that the sensor's values are read every 1 second. 
  •  I2C3

Afterward, I created one scenario with 2 queues: one (Queue 1) hosting the LPTIM1 Start box, and the other one (Queue 2) hosting the I2C3 Transmission and I2C3 Receive boxes. The I2C3 Receive "Number of Data" is set as 10. 

Test_00_Queue2.jpg

In the 'scenario_build.c' file, I initialize the data buffer (uint8_t Rx[10]) in which I would like the sensor data to be saved. Then, in the 'scenario_config.c' file, the LPTIM1 is started in the 'Scenario_Start' function while in the 'MX_Queue2_Q_DMA_TC_Callback' a UART transmission is performed to send all the data buffer values to a serial terminal, and the LPTIM1 is stopped. Finally, the LPBAM application-generated API call sequence (Init, Build, Link, Start) is performed in the 'main()' function. 

With these settings, the Rx buffer is not filled with data sampled every 1 s, so it is not sent after 10 seconds; all the sensor values are instead read by a single I2C transaction and sent after 1 second. 

 

2nd TEST (Test_02.rar in the attached files):

Both the "Pinout & Configuration" and the "LPBAM Scenario & Configuration" tabs are configured in the same way as in the first test. Also in this case, I created one scenario with 2 queues: one (Queue 1) hosting the LPTIM1 Start box, and the other one (Queue 2) hosting the I2C3 Transmission and I2C3 Receive boxes, as shown in the attached images. In this test, I have added as many I2C Receive boxes as my data buffer length (=10), each of them having "Number of Data" equal to 1 and increasing "Data Buffer Offset". 

Only in this case, I was able to successfully save all the data into each element of the buffer each 1 second, thus receiving all the data after 10 seconds. 

Test_02_Queue2.jpg

 

3rd TEST (Test_03.rar in the attached files): 

Both the "Pinout & Configuration" and the "LPBAM Scenario & Configuration" tabs are configured in the same way as in the previous tests. Also in this case, I created one scenario with 2 queues: one (Queue 1) hosting the LPTIM1 Start box, and the other one (Queue 2) hosting the I2C3 Transmission and I2C3 Receive boxes, as shown in the attached images. However, in this test, the I2C3 Receive "Number of Data" is set as 1, and Queue 2 is set in Circular mode. 

With these settings, only the first element of the Rx buffer is filled with data. I suppose that by enabling the circular mode all the sampled data is stored at the same memory address, thus all the acquired samples are overwritten at each I2C transaction. Of course, this also happens if I set the I2C3 Receive "Data Buffer Offset" with a value different than 0. In this case, the buffer is only filled in the position defined by the offset. 

Test_03_Queue2.jpg

Furthermore, when using the xNUCLEO-LPM01A Power Shield to analyze the uC current consumption, I notice that, in each test, the uC correctly goes to Stop2 mode but it seems that it never wakes up since the current values remain around 800 uA. 

Current_Consumption_10s.jpg

 

Here are some additional questions: 

Is there an available project implementing data storage into a buffer in LPBAM? My search did not yield any results yet.

- I have noticed that the I2C3 parameters settings present an "Autonomous Mode" tab. What is it used for? I couldn't find any information online. 

 

Thanks. 

Best regards

1 REPLY 1
tiny_programmare
Associate

Dear Ilaria,
Has anyone from ST helped you?
I am also interested in this topic, as I am having the same problems

I think that the low power capabilities of this micro are superb, but I find it difficult to get along with them. 

 

Best regards,

A.