Skip to main content
Starman
Associate III
April 16, 2021
Question

Why is the MCU disconnecting (due to the ST-LINK losing connection) from the GDB when enabling the SysTick (TICKINT) interrupt register?

  • April 16, 2021
  • 2 replies
  • 2142 views

I am using the ST-LINK which is built onto/attached to the Nucleo-F767ZI in order to connect to the MCU and interact with it.

I am trying to use SysTick but am unable to enable interrupts with it. Everything else appears to work as it should.

I initially tried this:

#include "./headers/stm32f767xx.h"
 
void init_sysTick(void)
{
 SysTick->LOAD = 18749UL; // set the reload value, speed is 18.75MHz
 SysTick->VAL = 0UL; // set the starting value
 SysTick->CTRL = 0b111; // enable SysTick, SysTick interrupt and set clock source to the processor clock
}

However, this was causing the GDB client to return the message of:

warning: Remote failure reply: E31

Remote communication error. Target disconnected.: No error.

And the GDB server to return the messages:

...

ST-LINK device initialization OK

TraceCaptureStart and SWV event set to APP_TRUE

ST-LINK device status: LOCKUP

Enter STM32_AppReset() function

NVIC_DFSR_REG = 0x0000000B

NVIC_CFGFSR_REG = 0x00000000

Error! Failed to read target status

Debugger connection lost.

Shutting down...

The same happens even when using the Cortex-M7 CMSIS drivers to initialise the SysTick too.

Though after playing around with the code a little, I modified the write to the control and status register (CTRL) to not enable the SysTick interrupt:

#include "./headers/stm32f767xx.h"
 
void init_sysTick(void)
{
 SysTick->LOAD = 18749UL; // set the reload value, speed is 18.75MHz
 SysTick->VAL = 0UL; // set the starting value
 SysTick->CTRL = 0b101; // enable SysTick and set clock source to the processor clock
}

I am able to run this without any issues or disconnections.

It is clear that there is an issue with enabling the interrupt, but I am unsure as to what specifically that issue is.

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
April 16, 2021

Is there a valid ISR handler, with properly inserted vector in the vector table, VTOR is set properly etc.?

Other interrupts work?

JW

Starman
StarmanAuthor
Associate III
April 17, 2021

forgot to mention that, sorry

i have included a valid ISR (or at least I believe it to be valid):

#include "../headers/global.h"
 
void SysTick_Handler(void)
{
 sysTicks++;
 if (sysTicks % 1000 == 0) seconds++;
}

and initialising the variables used in this ISR from the other file:

volatile uint32_t sysTicks = 0;
volatile uint32_t seconds = 0;

my startup file, which is one provided by ST, does contain a vector table. it is a standard one and i have not modified it. you can check it out here

the vector location should also be set properly, here is my linker file (I have kept only the relevant parts here, for the full file, check here:(

/* Define the end of RAM and the limit of stack memory */
/* (512KB SRAM on the STM32F767ZI line, 524288 = 0x80000) */
/* (RAM starts at address 0x20000000) */
ENTRY(reset_handler)
 
_estack = 0x20080000;
 
/* Set minimum size for stack and dynamic memory. */
/* (1KB) */
_Min_Leftover_RAM = 0x400;
 
MEMORY
{
 FLASH ( rx ) : ORIGIN = 0x08000000, LENGTH = 2048K
 RAM ( rxw ) : ORIGIN = 0x20000000, LENGTH = 512K
}
 
SECTIONS
{
 /* Put vector table at the start of flash. */
 .vector_table :
 {
 . = ALIGN(4);
 KEEP (*(.vector_table))
 . = ALIGN(4);
 } >FLASH
 
...

and yes, I have managed to get interrupts working before (although never attempted the SysTick interrupt before).

Tesla DeLorean
Guru
April 17, 2021

I've used SysTick on these parts with no issues, but I'm not using the GDB/OCD circus.

A​ WFI instruction has the potential to dump the whole Debug Interface, because it turns it off.

Point of note 2**32 is not divisible by 1000​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Starman
StarmanAuthor
Associate III
May 22, 2021

hey,

so after a few weeks, i've come back to this but started from scratch.

for some reason, i am no longer experiencing the same issue with the ST-LINK dropping out, which is great.

however, the SysTick_Handler interrupt does not appear to get called?

here is my new code: https://github.com/Starman3787/Stepper-Motor-Music

as before, i am using the standard startup file (with a vector table) which is provided by ST, so i highly doubt that is the issue here.