2012-10-25 12:49 PM
Hello,
I�m trying to use PA15 pin as an output on STM32F103CB chip, but with no luck. Because this pin is shared for JTAG, I must use remapping, First I enable clocks: RCC->APB2ENR |= RCC_APB2Periph_TIM1 | RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA; Then set up AFIO like this: uint32_t reg = AFIO->MAPR; reg &= ~(1<<24 | 1<<26);//JTAG-DP Disabled and SW-DP Enabled reg |= (1<<25); AFIO->MAPR = reg; Then i set up GPIOA reg = GPIOA->CRH; reg |= GPIO_CRH_MODE15;//output 50mhz reg &= ~(GPIO_CRH_CNF15);//gpio push-pull GPIOA->CRH = reg; And the damn thing does not work. neither through BSRR/BRR nor ODR I used the same code on STM32F107RC, and it works. When i tried on another 103 (STM32F103RB) it also did not work as output If i do not setup it, the internal pullup works as it should. Also to mention, other jtag pins PB3 and PB4 works as GPIO as they should. Any suggestions? #stm32f1032012-10-25 01:40 PM
GPIOA->CRH = reg; // perhaps?
STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\GPIO\JTAG_Remap\main.cRCC_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-10-25 01:50 PM
thanks clive1 for an answer, but this was not the error. here i only made a typo.
the real error was that in initialising UART1, i used someway uint16_t for CR which in result rewrite my previous settings of PA15. now the PA15 works as it should. case is closed