Saturday, April 28, 2012

ARM STM32 Study Note_5/Pin remap

People like me which started from avr microcontroller will thought one pin can only connect to one peripheral, but this is not true in STM32. In STM32, it introduced a new concept called pin remapping which provide engineers more flexibility to configure their peripheral mapping based on their need.

From the STM32F10xxx reference manual(RM0008), here is an example about USART1's pin remapping configuration:

By default, PA9 and PA10 is USART1's pin mapping, however, we are able to remap it to PB6 and PB7.

After remap the pins,first thing you need to do the is reconfigure the GPIO type for this pin:
   { GPIO_Mode_AIN = 0x0,
      GPIO_Mode_IN_FLOATING = 0x04,
      GPIO_Mode_IPD = 0x28,
      GPIO_Mode_IPU = 0x48,
      GPIO_Mode_Out_OD = 0x14,
      GPIO_Mode_Out_PP = 0x10,
      GPIO_Mode_AF_OD = 0x1C,
      GPIO_Mode_AF_PP = 0x18
    }GPIOMode_TypeDef;


Notes:
after setting the pin to Alternate funciton output, write to the corresponding output register wont work
but for alternate function input, you can still read the value from input data register.


No comments:

Post a Comment