2021-02-28 03:05 PM
Hello. Im using STM32L476RG nucleo. Im trying to debug bare metal code. Sadly my debug stops working when it gets to line where MODER register is configured.
Console says following: Target is not responding, retrying...
It keeps saying that until debugger loses connection.
The line where debuggur loses connection: GPIOA->MODER = 0x400;
However when i write same line with OR debugger is fine: GPIOA->MODER |= 0x400;
As soon as i remove OR(|) it crashes. The problem is with OR it won't change register values and my code won't work. Any solution?
#include "stm32l4xx.h" // Device header
void delayMs(int delay);
int main(void)
{
RCC->AHB2ENR |= 1; // enable GPIOA clock, 00000000000000000000000000000001
GPIOA->MODER = 0x400; // set PA5 as output, 0b 0000 0000 0000 0000 0000 0100 0000 0000, default value //0xABFFF7FF?
while(1){
GPIOA->ODR = 0x20; // set PA5 output data register 1, 0b .... 0010 0000
delayMs(100);
GPIOA->ODR &=~ 0x20;
delayMs(100);
}
}
void delayMs(int delay)
{
int i;
for(; delay>0; delay--){
for(i = 0; i<3195; i++);
}
}
Solved! Go to Solution.
2021-02-28 03:20 PM
PA13 and PA14 are SWDIO and SWCLK, i.e. the pins through which you run the debugger. Don't change the GPIO settings for them from the default (see GPIO chapter in RM), otherwise you lose the debugging capability.
JW
2021-02-28 03:20 PM
PA13 and PA14 are SWDIO and SWCLK, i.e. the pins through which you run the debugger. Don't change the GPIO settings for them from the default (see GPIO chapter in RM), otherwise you lose the debugging capability.
JW
2021-03-01 09:13 AM
Thanks a lot. I never thought about it. The answer was so easy and obvious. It is working now. Thanks again for pointing this out.