2012-12-04 06:32 AM
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!2012-12-04 07:51 AM
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);
2012-12-04 07:56 AM
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 regards2012-12-04 08:04 AM
Just using the standard FW library, V3.5.0, download from the resource tab for the part on the web site.
2012-12-04 10:25 PM
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?2012-12-04 11:43 PM
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?
2012-12-05 01:18 AM
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);
2012-12-05 02:56 AM
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?2012-12-05 06:23 AM
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.