2021-07-28 01:44 AM
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
Solved! Go to Solution.
2021-07-29 04:41 AM
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 !
2021-07-28 02:55 AM
> I just use the GPIOA->MODER register and reassign the bits I need to.
How?
JW
2021-07-28 04:03 AM
Hello,
When single stepping, at what line in the code do you loose the SWD connection ?
2021-07-28 04:04 AM
Hi, my line is :
GPIOA ->MODER |= (BIT12) ; //This put PA6 to output mode
2021-07-28 04:11 AM
The problem is I can't single step, when I put my program on the MCU, it disconnect immediatly, I can't even start it "normally, I have to use the reset user button to start it
2021-07-28 05:01 AM
That usually happens when you change the functionnality of the debug pins.
Your program is changing PA13 & PA14 configuration somewhere. Review your code.
Reset value for GPIOA->MODER is 0xA800 0000, make sure the 0xA8 part is not changed.
2021-07-28 05:04 AM
I've already done that and all is fine for these pins, and I should'nt be able to send my code if these pins are the problem
2021-07-28 05:08 AM
And even if I use GPIOC->MODER or GPIOB->MODER, the problem is the same
2021-07-28 05:13 AM
Do you turn off GPIOA clock somewhere ?
2021-07-28 05:20 AM
No it doesn't happen... But it gives me a question :
When I write something like "GPIOA->MODER |= BIT12", does the MCU test all the regiester's bit to assign the corresponding bit ? And if it is the case, can it be a problem for PA13 & PA14 ?