cancel
Showing results for 
Search instead for 
Did you mean: 

When I using interrupts with registers, I always encounter with an error which is "Target is not responding, retrying".. (STM32F407 Discovery Board)

AÃœNAL.1
Associate II

Hi,

I have a discovery board(STM32F407VG) and I am trying to blink one of the onboard LEDs with the button(PA0) interrupt. Actually the code is uploading on the board but it gives an error on the console ("Target is not responding, retrying"). So ı can't debug the code from the expressions,registers etc. But when I push the button, LEDs are blinking in the desired way.

If anyone knows this problem or anyone encountered with this problem, could you help me?

6 REPLIES 6
Bubbles
ST Employee

Hi @Alperen ÜNAL​,

what debug tools are you using? What console did you mention? Do you use low power modes in your code? Have you tried using STM32cubeprogrammer to connect to the running target and see the registers from there?

BR,

J

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

AÃœNAL.1
Associate II

Hi,

Thanks for your feedback.

I am using STM32CubeIde and console is the console windows where we see the errors etc. I didn't use STM32cubeprogrammer.

I am giving the code at below.

#include "main.h"

int count=0;

void SystemClock_Config(void);

#define PLL_M 4

#define PLL_N 168

#define PLL_P 0 // PLLP = 2

void CLK_Config(){

RCC->CR |= RCC_CR_HSEON; // RCC-CR |= 0x00010000;

while(!(RCC->CR & RCC_CR_HSERDY));

RCC->CR |= RCC_CR_CSSON;

RCC->PLLCFGR |= (PLL_M << 0) | (PLL_N << 6) | (PLL_P<<16) | (RCC_PLLCFGR_PLLSRC_HSE);

RCC->CFGR |= RCC_CFGR_HPRE_DIV1;

RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;

RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;

RCC->CIR |= RCC_CIR_HSERDYC;

RCC->CIR |= RCC_CIR_CSSC;

}

void GPIO_Config(){

RCC->AHB1ENR  = 0x00000009; // GPIOA ve GPIOD pinleri enabled

GPIOA->MODER  = 0x00000000;

GPIOD->MODER  = 0x55000000;

GPIOD->OTYPER = 0x00000000;

GPIOD->OSPEEDR = 0xFF000000;

GPIOD->PUPDR  = 0x00000000;

}

void EXTI_Config(){

RCC->APB2ENR = 0x00004000; // SYSCFG register enabled,EXTI

NVIC_EnableIRQ(EXTI0_IRQn);

   NVIC_SetPriority(EXTI0_IRQn,0);

EXTI->IMR = 0x00000001; // 0.Line interrupt enabled

EXTI->FTSR = 0x00000001; // Falling Edge

}

void EXTI0_IRQHandler(){

if(EXTI->PR & 0x00000001){

GPIOD->ODR=0x0000A000;

count++;

delay(1680000);

EXTI->PR = 0x00000001;

}

}

void delay(uint32_t time){

while(time--);

}

int main(void)

{

CLK_Config();

GPIO_Config();

EXTI_Config();

 SystemClock_Config();

 while (1)

 {

 GPIOD->ODR= 0x00005000;

 }

}

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 /** Configure the main internal regulator output voltage

 */

 __HAL_RCC_PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 /** Initializes the RCC Oscillators according to the specified parameters

 * in the RCC_OscInitTypeDef structure.

 */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

 RCC_OscInitStruct.HSIState = RCC_HSI_ON;

 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

 /** Initializes the CPU, AHB and APB buses clocks

 */

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

}

AÃœNAL.1
Associate II

Okeyi I figure out the problem,

When I changed this expression( "GPIOA->MODER  = 0x00000000;") with this expression ("GPIOA->MODER  |= (00 << 0);"), problem is solved.

Which PA pins are you shooting for? PA0 ?

ORing ZERO on isn't going to clear those bits

Use

GPIOA->MODER = (GPIOA->MODER & 0xFFFFFFFC) | 0; // PA0 as INPUT

The OR ZERO is superfluous, but the compiler will fold it.

What you want to avoid is breaking PA13 / PA14 used for the debugger's connection.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AÃœNAL.1
Associate II

Hi,

Sorry for the being late to answer.

Yes, I was shooting PA0 pin and thanks for the advise, I will use it :)

Hi,

Sorry for the being late to answer.

Yes, I was shooting PA0 pin and thanks for the advise, I will use it :)