cancel
Showing results for 
Search instead for 
Did you mean: 

Releasing JTDO/NJTRST from PB3/PB4 for GPIO use

arwani07
Associate II
Posted on September 08, 2016 at 02:58

Using a STM32L152RCT6 - currently testing software on 32L152CDISCOVERY board

I am trying to configure PB3 (JTDO) as an output GPIO, however I am not able to do so. 

The pin is always stuck at 1.471V (Vcc/2) Vcc= 2.95.

I removed SB101 the solder bridge which connected it to the ST-Link in an attempt to resolve the issue with no luck.

PB4 (NJTRST) is having a similar issue, however when a Bit_Reset is written to it by user it resets from ist original state (Pulled up - 2.9V)

RM0038 mentions

''For user software designs, note that:

 

 To release the debug pins, remember that they will first be configured wither in input-pull-up 

 

 (nTRST, TMS, TDI) or pull-down (TCK) or output tristate(TDO) for a certain duration after reset

 

 until the instant when the user software releases the pins.

 

 

 

 When debug pins (JTAG or SW or TRACE) are mapped, changing the corresponding IO pin

 

 configuration in the IOPORT controller has no effect.''

How do I release these pins, PB3 and PB4. 

Couldn't find any example code or proper explanation. 

Any suggestions welcome!

#!stm32 #stm32l152 #stm32l-jtag-swd-gpio-reuse
7 REPLIES 7
christoph2399
Associate II
Posted on September 08, 2016 at 08:43

sometimes every you want to know you'll find in the reference-manual of your ST device..

quote:

32.4.4  Using serial wire and releasing the unused debug pins as GPIOs

To use the serial wire DP to release some GPIOs, the user software must change the GPIO 

(PA15, PB3 and PB4) configuration mode in the GPIO_MODER register. This releases 

PA15, PB3 and PB4 which now become available as GPIOs.
arwani07
Associate II
Posted on September 08, 2016 at 09:52

Thanks for that chris

 

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_StructInit(&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;

GPIO_Init(GPIOA, &GPIO_InitStructure);

The above is my code and I believe it does what you quoted. PB3 remains stuck on 1.4V....

I am lost as to what I else I can try to solve this.

I've already tried remapping an alternate function to the pins... with no luck

christoph2399
Associate II
Posted on September 08, 2016 at 11:57

1. you have to change your debug-settings from JTAG to SWD. if you change mode pins will debugging with JTAG your debug-session is likely to crash.

2. change to the desired mode, e.g. output-pushpull with HAL_GPIO_Init()

3. set the pin when in output to desired level, e.g. HAL_GPIO_WritePin( , GPIO_PIN_RESET)

4. check your hardware / schematic if you have some connected components on this pin/net which mess up your voltage-level
arwani07
Associate II
Posted on September 12, 2016 at 01:18

I've done all the steps and the problem is still persistent...

 Here's a video of what happens

https://www.youtube.com/watch?v=RZcpJspHfP8

Posted on September 12, 2016 at 02:54

Remove the LCD/GLASS

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arwani07
Associate II
Posted on September 12, 2016 at 05:45

I removed it and still no change, not sure why you told me to remove it? 

I am using a micro on an external pcb that isn't connected to the LCD. I am just using the ST/Link on the discovery board to program my micro.

I still do not know how to release the pins ...

0690X000006038mQAA.jpg

stm32forum
Associate II
Posted on September 12, 2016 at 11:12

This is how CubeMx does it:

First make the pins low, then setup for output.

static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4|GPIO_PIN_3, GPIO_PIN_RESET);
/*Configure GPIO pins : PB4 PB3 */
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}