STM32F411 needs more than 100 clocks for an ISR call and return

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
sams_n
Posts: 7
Joined: 30 Apr 2023 15:38

STM32F411 needs more than 100 clocks for an ISR call and return

#1 Post by sams_n » 01 May 2023 10:55

Hello MikroE Team,
Hello MikroBasic users,

I am absolutely new to the use of 32bit controllers.
Until now I have been working a lot with AVR's and Bascom.
I have also done some programming in assembler.
But now I need a controller with much more speed for trigonometric calculations, 5 external interrupts and some outputs.
I thought the STM32F411 would be good for this.
Floating point calculation, 168MHz .....
But now I had to realise that an interrupt call and the return from the ISR takes a lot of clocks on an STM411.
Into the ISR 51 clocks, back out of the ISR 53 clocks.
Is that normal ?
If I test it with a STM32F103, this only needs
17 clocks into the ISR and 19 clocks out.
(according to the MicroBasic debugger).
What am I doing wrong here?

Best regards , Gerhard

Code: Select all

' * Project name:
'     external_interrupt

' * Test configuration:
'     Device:          STM32F103
'     Device:          STM32F411

program External_interrupt
 
sub procedure ExtInt() iv IVT_INT_EXTI15_10 ics ICS_AUTO
  EXTI_PR.B10 = 1                     ' clear flag
  GPIOA_ODR = not GPIOA_IDR           ' Togle PORTA
end sub

main:
  GPIO_Digital_Output(@GPIOA_BASE, _GPIO_PINMASK_HIGH)  ' Enable digital output on PORTA
  GPIOA_ODR = 0xAAAA
  GPIO_Digital_Input(@GPIOD_BASE, _GPIO_PINMASK_10)  'Pin PortD.B10 is input
  SYSCFGEN_bit = 1                       ' STM32F411  Enable clock for alternate pin functions
  SYSCFG_EXTICR3 = 0x00000300            ' STM32F411  Map external interrupt on PD10
  'RCC_APB2ENR.AFIOEN = 1                ' STM32F103  Enable clock for alternate pin functions
  'AFIO_EXTICR3 = 0x0300                 ' STM32F103  PD10 as External interrupt
  EXTI_RTSR =  0x00000400                ' Set interrupt on Rising edge
  EXTI_IMR = EXTI_IMR or 0x00000400      ' Set mask
  NVIC_IntEnable(IVT_INT_EXTI15_10)      ' Enable External interrupt

  EnableInterrupts()                     ' Enables the processor interrupt.

  while(TRUE)
    nop
  wend                    ' Infinite loop
end.

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: STM32F411 needs more than 100 clocks for an ISR call and return

#2 Post by Thomas.Pahl@t-online.de » 03 May 2023 14:29

The 411 is made for 100MHz. I haven't tested it with 168MHz. It is possible that the startup routine tests the flash timing and adds extra waiting clocks. If you need calculating power, take the 407. I have got it running at 240MHz.

sams_n
Posts: 7
Joined: 30 Apr 2023 15:38

Re: STM32F411 needs more than 100 clocks for an ISR call and return

#3 Post by sams_n » 03 May 2023 17:22

Hello Thomas,
thanks for the tip with the STM32F407.
But my question is, why does the 411 need so much more clocks to get in and out of the ISR than a STM32F103.
I have to read 5 clock lines with up to 250kHz per interrupt, so I can't use this waste of time.
The interrupt times of the STM32F103 would be o.k. but the trigonometry calculation needs about 10x as many clocks as the 411.

Post Reply

Return to “mikroBasic PRO for ARM General”