That's a tricky one to answer.
But the biggest expenditure of time is the I2C traffic. You will need to tranfer 64 16-bit distances, 64 32-bit signal strenghts, 64 8-bit target numbers and 64 8-bit status values. And there are 15 of these per second.
So keep that in mind.
But rather than give you a number I want to give you some code.
Figure out where you want to measure and add the code.
If you use the STSW-IMG035_F401 it runs at 84MHz,
I know I'm making you do the work. But everyone should know this trick.
Just add these defines in your code and then the functions. Simply call the stopwatch_reset to both enable the counter and it resets it to 0. Then do the stopwatch_getticks to get the current value. I also add in my watch expressions the *0xE0001004, so if I put in a break point, I can see the current value of the counter.
// Defines to be added
#define DEMCR_TRCENA 0x01000000
/* Core Debug registers */
#define DEMCR (*((volatile uint32_t *)0xE000EDFC))
#define DWT_CTRL (*(volatile uint32_t *)0xe0001000)
#define CYCCNTENA (1<<0)
#define DWT_CYCCNT ((volatile uint32_t *)0xE0001004)
#define CPU_CYCLES *DWT_CYCCNT
// Functions to be added.
static inline void stopwatch_reset(void)
{
/* Enable DWT */
DEMCR |= DEMCR_TRCENA;
*DWT_CYCCNT = 0;
/* Enable CPU cycle counter */
DWT_CTRL |= CYCCNTENA;
}
static inline uint32_t stopwatch_getticks(void)
{
return CPU_CYCLES;
}
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.