Hello,
I have a weird issue with my STM Timer. Here is my setup: I have the old Dolphin DCC Kit with a S32R274 and a TEF810x and a Matlab skript, which configures a chirp at the beginning and triggers it repeatedly via ethernet. Whenever a chirp triggers I want to measure the time it takes until the acquisition is completed and I want to do some other stuff, every 50µs. I did this using the STM1 timer.
The problem is that the timer only wants to count after I have enabled a debug breakpoint after the line that starts it. Otherwise it seems like the CPU skips its activation. After going through the breakpoint once it works for further chirps without issues. This holds only until I restart the Matlab skript, which reconfigures the chirp again. The chirp configuration only touches MIPI and SPT registers and does communication via SPI (Any waiting in this part is done via NOP loops). Then it gets skipped again until I stop at the breakpoint again.
This is how I programmed the timer and the only place any STM registers are touched (I checked).
void STM1_start(void){
STM_1.CR.R = 0x0; // Disable timer (stop counter)
STM_1.CNT.R = 0; // Clear counter.
STM_1.CR.R = 0x00000001; // Divide system clock by 1 & enable timer
}
uint32_t STM1_stop(void){
uint32_t stm_data;
STM_1.CR.R = 0x0; // Disable timer (stop counter)
stm_data = STM_1.CNT.R; // Store time results
STM_1.CNT.R = 0; // Clear counter.
return stm_data;
}
uint32_t STM1_get(void){
return STM_1.CNT.R;
}
And this is how I use it (In Core0 exclusively):
const uint32_t delayTicks = 50 * STM_uSecBase;
uint32_t targetTicks = delayTicks;
StartChirp();//Trigger TEF810x via SPI
STM1_start();
while(Waiting4Chirp()){//Wait until aquisition complete by polling SPT flag
if(STM1_get() >= targetTicks){
targetTicks += delayTicks;
doThings();
}
}
targetTicks = STM1_stop();
print(targetTicks);
Any help is very appreciated, as I dont even have an idea where to look at anymore.