cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, I'm using STM32l152RCT6 and i have a debugging problem with GPIOx->MODER

CBonn.1
Associate II

In my program I have to change the mode of 2 pin very frequently, I have to get from Input mode (to have an "high impedance" state) to output mode (to use a PP) etc. These pins are PA6 and PA7.

And it's working, no problems to do that, I just use the GPIOA->MODER register and reassign the bits I need to.

But when I do that i have a problem : I can start debugging, charge the program through the board, but then I immediatly lose connexion with it. So I can't do any observation during debbuging (no "step by step", no variable visualisation...).

I have already found that this problem is here when I assign a bit on MODER register, when I don't do this I can debug easily.

I don't change the mode of PA13 and PA14, so the problem is not that I can't use the SWD process anymore (also if it was that, I would not be able to charge the program on the MCU).

Another thing that I don't understand is that depend on where I put this line on my program, it can work (I do a "calibration" cycle before my main loop, and this is when the problem appears)...

Also, if I try to do this on another PIN and use another register (like GPIOC->MODER for example), the problem remains the same...

Does anyone have an idea ? 🙂

Edit : here the messages I have in the console :

Info : Previous state query failed, trying to reconnect

Error: jtag status contains invalid mode value - communication failure

Polling target STM32L152RCTx.cpu failed, trying to reexamine

Examination failed, GDB will be halted. Polling again in 6300ms

13 REPLIES 13

Just to test, please replace GPIOA->MODER |= BIT12 with the following line :

GPIOA->MODER = 0xA8001000;

Thank you for your help, unfortunatly it does exactly the same...

I see, sorry, without code+schematics, I can't make more suggestions.

CBonn.1
Associate II

Ok so I've finally found how to solve it :

I tried of course to clean then rebuild the project many time, but it didn't change anything...

I tried one last thing that worked for some reason :

put away all my files, then take them back to the project.

I build the project, start to debugging and now it is working !