VTFT STM32 Timer Interrupt Problem

General discussion on Visual TFT Software.
Post Reply
Author
Message
majo
Posts: 7
Joined: 19 Aug 2011 19:30

VTFT STM32 Timer Interrupt Problem

#1 Post by majo » 25 May 2020 10:34

Hi,
i made a visual TFT-Project with some additional code. It all worked fine until i implemented an
interrupt function for timer2;
I used your timer calculator for the interrupt.

Code: Select all

//Timer2 Prescaler :11; Preload = 62499; Actual Interrupt Time = 5 ms

//Place/Copy this part in declaration section
void InitTimer2(){
  RCC_APB1ENR.TIM2EN = 1;
  TIM2_CR1.CEN = 0;
  TIM2_PSC = 11;
  TIM2_ARR = 62499;
  NVIC_IntEnable(IVT_INT_TIM2);
  TIM2_DIER.UIE = 1;
  TIM2_CR1.CEN = 1;
}

void Timer2_interrupt() iv IVT_INT_TIM2 {
  TIM2_SR.UIF = 0;
  //Enter your code here
  //  LastMessBolzen.ADC_RawValue = c420mar_getADCvalue();
  //  Filter( &LastMessBolzen );
  Delay_ms(3);
  //  Frequenzumrichter.ADC_RawValue = ADC1_Get_Sample(8);
  //  Filter( &Frequenzumrichter );

} 
If i start the timer interrupt the program hang after a little while in this section:

_I2Cx_Get_Status:
;__Lib_I2C_123.c, 160 ::
; I2C_BASE start address is: 0 (R0)
0x01A0 0xB081 SUB SP, SP, #4
; I2C_BASE end address is: 0 (R0)
; I2C_BASE start address is: 0 (R0)
;__Lib_I2C_123.c, 163 ::
0x01A2 0xF2000114 ADDW R1, R0, #20
0x01A6 0x680A LDR R2, [R1, #0]
;__Lib_I2C_123.c, 164 ::
0x01A8 0xF2000118 ADDW R1, R0, #24

It looks like some I2C routines for the touch panel.
The timer interrupt still works fine.
I use a mikromedia plus for STM32 ARM and the newest version of VTFT and Compiler.

Do you have any tips to solve this Problem?
Best Regards
Mario

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: VTFT STM32 Timer Interrupt Problem

#2 Post by jovana.medakovic » 26 May 2020 11:26

Hello,

It seems like your clock settings are incorrect.
Can you zip and send me your project for a review?

Kind regards,
Jovana

majo
Posts: 7
Joined: 19 Aug 2011 19:30

Re: VTFT STM32 Timer Interrupt Problem

#3 Post by majo » 27 May 2020 12:25

Hi Jovana,

thanks for your answer. You find the Project attached to this reply.
Best Regards
Mario
Attachments
Last_neu.zip
(1.21 MiB) Downloaded 62 times

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: VTFT STM32 Timer Interrupt Problem

#4 Post by jovana.medakovic » 29 May 2020 15:52

Hi Mario,

You didn't set the timer correctly.
Try with this:

Code: Select all

void InitTimer2(){
  RCC_APB1ENR.TIM2EN = 1;
  TIM2_CR1.CEN = 0;
  TIM2_PSC = 5;
  TIM2_ARR = 62499;
  NVIC_IntEnable(IVT_INT_TIM2);
  TIM2_DIER.UIE = 1;
  TIM2_CR1.CEN = 1;
}
 
void Timer2_interrupt() iv IVT_INT_TIM2 {
  TIM2_SR.UIF = 0;
  //Enter your code here
}
Kind regards,
Jovana

majo
Posts: 7
Joined: 19 Aug 2011 19:30

Re: VTFT STM32 Timer Interrupt Problem

#5 Post by majo » 01 Jun 2020 16:01

Hi Jovana,

thanks for your reply. Your are right, my timebase was 10ms instead of 5ms.
But that did not solve the problem of corse. The Visual TFT routines still hangs up
at the same point.
You can try this. The program runs on mikromedia+ for STM32 also a click board 4...20R is installed.

Best Regards
Mario

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: VTFT STM32 Timer Interrupt Problem

#6 Post by jovana.medakovic » 02 Jun 2020 11:13

Hi Mario,

You should not have a delay in the Timer function.
You set the timer to 5ms and inside the timer function, you have a delay of 3ms. This delay causes the program to hang. If you delete this line, your code should work fine.

Kind regards,
Jovana

majo
Posts: 7
Joined: 19 Aug 2011 19:30

Re: VTFT STM32 Timer Interrupt Problem

#7 Post by majo » 02 Jun 2020 12:10

Hi Jovana,

as you maybe can imagine this delay function was just for debugging reasons.
Maybe you have seen the actual code lines are commeted out. I just want to make sure
that there is no bug in my code.
However there is the same result other i use my code or the delay function!

Could you explain this?
You set the timer to 5ms and inside the timer function, you have a delay of 3ms. This delay causes the program to hang. I
In my understanding the main program should be more slowly, because it has only 2 of 5ms to run. But that is not the case the program always
hangs up in the region with I2C routines from VTFT as mentioned in my first message.

To follow your advice I have removed the delay and uncommented Parts of my code again.
Like this:

Code: Select all

void Timer2_interrupt() iv IVT_INT_TIM2 {
  TIM2_SR.UIF = 0;
  GPIOD_ODR.B13 = 1;
  //Enter your code here
    LastMessBolzen.ADC_RawValue = c420mar_getADCvalue();
    Filter( &LastMessBolzen );
  //Delay_ms(3);
  //  Frequenzumrichter.ADC_RawValue = ADC1_Get_Sample(8);
  //  Filter( &Frequenzumrichter );
  GPIOD_ODR.B13 = 0;
}
I toggelt a pin to measure the time this two function need.
LastMessBolzen.ADC_RawValue = c420mar_getADCvalue();
Filter( &LastMessBolzen );
The Result is 550us. However the main program still hangsup on the same point in mE routines.

Best Regards
Mario

majo
Posts: 7
Joined: 19 Aug 2011 19:30

Re: VTFT STM32 Timer Interrupt Problem

#8 Post by majo » 09 Jun 2020 07:10

Hi Jovana,

do you still help me or should i move to the Helpdesk?

Best Regards
Mario

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: VTFT STM32 Timer Interrupt Problem

#9 Post by jovana.medakovic » 10 Jun 2020 16:13

Hello,

In the timer interrupt routine, you should not call another function, so I recommend you set some flag in the interrupt routine and in the main function, you should check if the interrupt occurred and there write a program.

Kind regards,
Jovana

majo
Posts: 7
Joined: 19 Aug 2011 19:30

Re: VTFT STM32 Timer Interrupt Problem

#10 Post by majo » 12 Jun 2020 11:35

Hi Jovana,

thanks for your reply. In other words VTFT is not interrupt save.
If you said this clearly in your first reply we could save over two weeks of conversation
and a lot of time....

Best Regards Mario

Post Reply

Return to “Visual TFT General”