How to generate a timestamp between two data readings

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I am using PSoC 4 to develop a sensor. I need to timestamp the data I read, then I will only send the peaks and their timestamps to a mobile phone.

When I code:

#include<AFE4403_Sample.h>

#include<time.h>

#include <sys/time.h>

// afe4403 sample data

void AFE4403_Sample(int *num, uint32 (*data)[350])

{

    uint32 temp1;

    int n=0;

    time_t stop,start;

    double Timestamp[350];

  

    start=time(NULL);

    if (*num<50)       // num = 340 when work; num = 34 when debug

    {

        while(n<350)

        {

            temp1=BLE_AFE4403_ReadData(0x2A,0x00);  /

            temp1=temp1& 0xffffff;  //set the highest two bits to 0

            CyDelay(10);

            stop=time(NULL);

            Timestamp = difftime(stop, start);

      

            (*data)=temp1;

            n++;

        }

    }

}

My Timestamp[350] array will have 350 times the same value. Does anyone know how to get the time difference between the start of AFE4403_Sample and the reading of my data?

Regards,

Elias

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will need to maintain your own time. When you need an absolute time stamping have a look at the RTC Component.

When only a relative time is needed a Timer component which fires an interrupt to update the current time will do.

Bob

View solution in original post

0 Likes
5 Replies