cancel
Showing results for 
Search instead for 
Did you mean: 

JTAG remap on STM32F103C8T6

bond1
Associate II
Posted on December 04, 2012 at 15:32

Hi,

I have this issue:

PB3 and PB 4 should be a GPIO in push/pull.

For PB4 the remap and configuration works fine, but i cant get a high level out of PB3.

Here is my code:

RCC->APB2ENR |=1;             /* Enable AFIO clock                  */ //disable JTAG ->

 AFIO->MAPR |= (1<<26);    // disable jtag & sw

 // set GPIOBL

 GPIOB->CRL = 0x333AA333; // set PB3 and PB4 to alternate push pull

Is something missing / wrong?

Thanks!
8 REPLIES 8
Posted on December 04, 2012 at 16:51

This should work to convert SWD/JTAG to GPIO

GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); 
/* Disable the Serial Wire Jtag Debug Port SWJ-DP */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
/* Configure PA.13 (JTMS/SWDAT), PA.14 (JTCK/SWCLK) and PA.15 (JTDI) as
output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure PB.03 (JTDO) and PB.04 (JTRST) as output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOB, &GPIO_InitStructure);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bond1
Associate II
Posted on December 04, 2012 at 16:56

Hi Clive1,

Thanks for your prompt response. What library are you using? Can I get the sourcecode for this functions & constants?

Thanks a lot, best regards

Posted on December 04, 2012 at 17:04

Just using the standard FW library, V3.5.0, download from the resource tab for the part on the web site.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bond1
Associate II
Posted on December 05, 2012 at 07:25

Hi again,

I've just looked into the lib, but i could not find a major difference between the register settings done by the lib, and the register settings done by my code.

The only difference might be the initialization of PORTA, this is done in a different way - and PORTA works properly.

Any ideas regarding register values?

bond1
Associate II
Posted on December 05, 2012 at 08:43

Is there anyone, who has ever successfully set up the remap for the GPIOs on the JTAG interface WITHOUT using the ST stnadard peripheral lib?

zzdz2
Associate II
Posted on December 05, 2012 at 10:18

I do it this way but I only tested PA13 used as USB pullup:  // disable JTAG:

RCC->APB2ENR |= RCC_APB2ENR_AFIOEN;

AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_SWJ_CFG) | AFIO_MAPR_SWJ_CFG_DISABLE;

RCC->APB2ENR &= ~RCC_APB2ENR_AFIOEN;   config the pin as PP:

mask = 0x00100000;

GPIOA->CRH = (GPIOA->CRH & ~(mask * 0xf)) | (mask * GPIO_CRH_MODE8_1);

 

bond1
Associate II
Posted on December 05, 2012 at 11:56

Thanks for the hint. Unfortunately, stopping the clock to AFIO does not solve the problem.

I've just tried to get this ST library running with Keil, but the GPIO_InitStructure can't be found.

Do you know in which file i can find it?

zzdz2
Associate II
Posted on December 05, 2012 at 15:23

I think you should declare it as GPIO_InitTypeDef

Edit: I just measured it and it behaves the same here:

PB4 works well, PB3 doesn't work, weird.