cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042F4: using PA11 and PA12 as IO

bastiaan
Associate
Posted on August 11, 2015 at 14:20

I'm trying to use PA11 and PA12 on a TSSOP20 STM32 as output to understand how this remapping and configuring works. Until now I'm unable to get it to work, the pins do not toggle.

Can someone point me to the mistake I'm making? Here's what I did:

/* Remap PA11 and 12 */
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
SYSCFG->CFGR1 = SYSCFG->CFGR1 & SYSCFG_CFGR1_PA11_PA12_RMP;
/* Set to outputs */
 RCC->AHBENR |= RCC_AHBENR_GPIOAEN;

GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER11 | GPIO_MODER_MODER12))\
| (GPIO_MODER_MODER11_0 | GPIO_MODER_MODER12_0);
/* Try to toggle outputs */
GPIOA->ODR ^= GPIO_ODR_11;
GPIOA->ODR ^= GPIO_ODR_12;

#pa11-pa12-remapping-stm32f042f4
1 REPLY 1
Posted on August 12, 2015 at 11:20

SYSCFG->CFGR1 = SYSCFG->CFGR1 & SYSCFG_CFGR1_PA11_PA12_RMP;

&? In doubts, I often read back the registers and check whether they are set as I expect them to be. This is best done in the debugger (where the writes can be done directly too); I understand that this may not be practical with the 20-pin package. JW