2016-12-14 01:27 AM
Hello,
did anyone ever manage to get PB3 working as an I/O port on an STM32F103?
I am having a hard time with the F103VB where I need PB3 as input - no matter what I try, PB3 simply is returning a 0 value.
AFIO->MAPR is set to SWD debug only, JTAG off (and AFIO clock is on, of course).
I also explicitly set DBGMCU_CR to turn TRACE off, although that should be default after reset.
The other two related port pins (PB4 and PA15) work perfectly fine as GPIO. Only PB3 simply appears dead.
The errata sheet also doesn't mention any problems with PB3 as GPIO.
Did I find a new bug?
Any help is greatly appreciated.
Thanks, Tilmann
2016-12-14 10:42 AM
Hi reh.tilmann,
If you want to use the PB3 as a GPIO pin, you should not use the asynchronous trace over the SW debug.
Lawliet.
2016-12-14 03:26 PM
Hello Lawliet,
I really appreciate that you want to help - but did you read the previous posts, starting with the very first one?
I do not use async trace, and mentioned that often.
Tilmann
2016-12-14 04:25 PM
What debugger hardware and software are you using?
Been years since I was actively building with F1 parts but don't recall PB3 being unusable.
2016-12-15 02:15 AM
Hello everybody,
problem solved - indeed it was a small typo in the MAPR assignment, so in fact JTAG was not disabled in the application code. The bootloader didn't have that typo, so JTAG was disabled there, but during initialization of the application all peripherals are reset - and it appears that this partially resets the JTAG port assigment... (Remember that PB4 and PA15 still worked as GPIO, that's why I didn't notice that typo for such a long time (and obviously I overlooked it very many times when checking the code)).
Sorry, my fault. Now PB3 works as expected.
Tilmann
2016-12-15 03:22 AM
>problem solved - it was a small typo in the MAPR assignment
This is why I asked you to post the read-back content of relevant registers.
JW
2016-12-15 03:32 AM
Remember that particularly these bits of MAPR are write-only, unfortunately.
Tilmann
2016-12-15 03:41 AM
>Remember that particularly these bits of MAPR are write-only, unfortunately.
Ah, I did not know that, sorry then. I don't 'F1.
Jan
2017-03-12 12:35 AM
Hello Tilmann,
I'm having the same problem.
Not sure, how did you solve the GPIO PB.3 problem?
You had mention '
small typo in the MAPR assignment
' , in my case I call once to: AFIO->MAPR = 0x02000000; and still it doesn't work. Please be more specific what is the fixed value you wrote to MAPR?Thanks In Advance,
Micha
2017-03-12 05:43 AM
Don't you use the 'asynchronous trace', enabled possibly by your toolchain (maybe by enabling some form of 'semihosting' )?
JW
2017-06-01 08:59 AM
I am having the same problem. I am using the STM32 peripherals library for configuration, so my init code looks like this:
// Disable JTAG, keep SWD => Enable PB3, PB4 for GPIO output
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);// Activate port B periphery
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);// PB3 (output, high active): PP
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOB, &GPIO_InitStructure);// PB4 (output, high active): PP
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOB, &GPIO_InitStructure);As a result, PB4 works as expected, but PB3 doesn´t.
I am using Atollic TrueStudio, so it may be that 'asynchronous trace' is enabled. However, I cannot find any option to configure it - and Google is _not_ my friend (i.e. couldn´t find how to turn 'asynchronous trace' off in Atollic).
Anybody any idea?