Hello Lukas,
Thanks for sharing the project.
I went through the project.Where are you enabling the particular timers and channels of STM?
void STM0_init(uint32_t channel, uint32_t vSTM_CMP)
{
STM_0.CHANNEL[channel].CMP.R = vSTM_CMP + STM_0.CNT.R; /* STM channel x compare value */
STM_0.CHANNEL[channel].CIR.R = 1; /* clear STM channel x interrupt */
STM_0.CHANNEL[channel].CCR.R = 1; /* enable STM channel x */
}//STM0_init
in above code part
STM_0.CHANNEL[channel].CMP.R = vSTM_CMP + STM_0.CNT.R; /* STM channel x compare value */
why you are adding STM_0.CNT.R in compare register will it not affect the intervals of interrupts?
And when the CMP value reaches to maximum value how it is handled?
In my case I am initializing CMP register with one value and in ISR I am adding same value to it and not adding the CNT value in CMP register.
Same issue I am facing with the PIT timer
/* 0.5 us interrupt*/
ISR(PIT_CH0)
{
PIT.TIMER[0].TFLG.B.TIF = 1; /* clear PIT CH0 IR flag */
}
/* 0.9 us interrupt*/
ISR(PIT_CH1)
{
PIT.TIMER[1].TFLG.B.TIF = 1; /* clear PIT CH0 IR flag */
}
in this PIT timer case I am only getting PIT_CH0 interrupt always not getting PIT_CH1 anytime but if individually if I am checking I am able to get both the interrupts.
For STM2 channel 0 I want an interrupt every 0.2 microseconds and on STM2 channel 1 I want an interrupt every 0.5 microseconds.
Input clock to STM is 80 MHz, so 1/80MHz= 12.5 nanoseconds
For 0.3 microseconds interrupt CMP register needs to fill with 0.1 microseconds/12.5 nanoseconds which is 18 in Hexadecimal
so
ISR(STM2_0)
{
CMP_STM2_0 = CMP_STM2_0 + 0x00000018;
STM_2.CHANNEL[0].CMP.B.CMP = CMP_STM2_0; /* Compare value for channel 0 of STM2*/
STM_2.CHANNEL[0].CIR.B.CIF = 1; /* clear STM2 CH0 IR flag */
}
ISR(STM2_1)
{
CMP_STM2_1 = CMP_STM2_0 + 0x00000028;
STM_2.CHANNEL[1].CMP.B.CMP = CMP_STM2_1; /* Compare value for channel 0 of STM2*/
STM_2.CHANNEL[1].CIR.B.CIF = 1; /* clear STM2 CH0 IR flag */
}
where CMP_STM2_0 is initialized with 0x00000018 and CMP_STM2_1 is initalized with 0x00000028.
Is these calculations are correct. In reference manual PIT calculation is mentioned but STM calculation is missing.
And how the priorities are handled? I am assigning the same priorities to all the channel interrupts.
Could you help in this?
Thanks & Regards,
Shweta