2013-08-14 09:11 AM
Hello,
I am attempting to remap pins PD0 and PD1 as GPIO and whenever I try to change the pin state, it stays low. Am I setting something up wrong? Init Code: GPIO_InitTypeDef GPIO_InitStructure; /*GPIOD Output Initialization*/ //Disable HSE RCC->CR &= 0xFEFF; //Drive source and destination enable signals //Enable the GPIOD peripheral RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); //Re-map PD0 and PD1 as GPIO pins GPIO_PinRemapConfig(GPIO_Remap_PD01, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; //Set the pin(s) to output mode, Push Pull GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //initialize the above settings GPIO_Init(GPIOD, &GPIO_InitStructure); Code used for toggling: GPIOD->ODR &= ~(GPIO_Pin_0|GPIO_Pin_1); GPIOD->ODR |= (GPIO_Pin_0|GPIO_Pin_1); Thanks in advanced! #pd0-pd1-gpio-remap-stm32-f1032013-08-14 10:02 AM
Am I setting something up wrong?
You want them as GPIOs, configure them as such
/* GPIOD Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
/* Configure PD0 and PD1 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
2013-08-14 11:20 AM
I tried that but it didn't work. I guess the pins' default function is the high speed external oscillator. To access the GPIO, the reference manual said to remap the pins. Unfortunately I can't get that to work properly (Code posted above). Any ideas?
2013-08-14 11:25 AM
For a ReMap to work you'd need to enable the clock on the AFIO peripheral
2013-08-14 11:37 AM