Hi,
currently I'm programming my F28377S which I use for realtime adc tests. I want to save my test results together with a timestamp.
I want to do this by the use of the clock-cycle counter. I want to know the amount of cycles since the program was started. Usually I would use the timer.h library and clock(). However, when I do so, this results in an output: 0.
The next thing I tried is using the CpuTimer0Regs. This did work in the sense that I got numbers up to 300. The code I used is the following:
timestampH = CpuTimer0Regs.TIM.bit.MSW; timestampL = CpuTimer0Regs.TIM.bit.LSW; sendString[6] =(int) (timestampL) & 0xFF; // first 8 bits of timestamp sendString[7] =(int) ((timestampL >> 8)) & 0xFF; // second 8 bits of timestamp sendString[8] =(int) (timestampH) & 0xFF; // third 8 bits of timestamp sendString[9] =(int) ((timestampH >> 8)) & 0xFF; // fourth 8 bits of timestamp
However, the maximum output here is around 300, loop of 10 around my full program result in the following timing outputs:
0
328
294
41
189
337
84
232
392
139
for the complete programming part see below
//volatile uint32_t timestamp;
uint16_t timestampH;
uint16_t timestampL;
bool curVolBit = 0;
int matrixNmbr = 2;
int nodeNmbr = 612;
int curVol = 987;
for(x = 0; x < 20; x++){
//timestamp = CpuTimer0Regs.TIM.bit.MSW;// + (CpuTimer0Regs.TIM.bit.MSW << 16);
timestampH = CpuTimer0Regs.TIM.bit.MSW;
timestampL = CpuTimer0Regs.TIM.bit.LSW;
sendString[0] = '€'; //icon for start of packet
sendString[1] = 'R'; //icon for Reading instruction
sendString[2] = (matrixNmbr & 0x03) + (curVolBit << 2) + ((nodeNmbr & 0x03) << 6); // bit 0-1 = matrixNmbr, bit 2 = curVolBit, 6-7 = nodeNmbr first 2 bits
sendString[3] = (nodeNmbr >> 2) & 0xFF ; // nodeNmbr last 8 bits
sendString[4] = curVol & 0xFF ; // first 8 bits of curVol
sendString[5] = (curVol >> 8) & 0xFF;// last 8 bits of curVol
sendString[6] =(int) (timestampL) & 0xFF; // first 8 bits of timestamp
sendString[7] =(int) ((timestampL >> 8)) & 0xFF; // second 8 bits of timestamp
sendString[8] =(int) (timestampH) & 0xFF; // third 8 bits of timestamp
sendString[9] =(int) ((timestampH >> 8)) & 0xFF; // fourth 8 bits of timestamp
curVol += 10;
for(z = 0 ; z < 30; z++)
SCI_write(&sendString[z], 1);
}
it seems that only a part of the timer gets updated. Does anyone know a better timer or a way how to fix this? knowing the clockcycles is enough to me.