2016-08-23 08:43 PM
I have a STM32F401re Nucleo board + Segger.edu J-Link. I am monitoring I2C signals using an Intronix LogicPort serial bus decoder. The development system is Rowley-Crossworks (v3.6.5.2016061400.2836 :) for ARM, which seems pretty good for the .edu licen$e.
I'm having a bit of trouble understanding how the alternate function routing works. I have read everything that I can put my eyeballs on and I went back 7 years on the forum reading all the posts re; F4s. I am using the CMSIS GPIO_TypeDef structs/defines and am avoiding library usage to understand things. On pg 164, of ''STM32F401xD_E_Ref_Man RM0368 rev4'', Table 27 depicts GPIOx_AFRL & GPIOx_AFRH 32bit registers. Then, on page 46, ''STM32F401xD STM32F401xE DS'' (DM00102166.pdf /docID025644 Rev 3), Table 9, are depicted ''Alternate Function Mapping''. How do these two 'things' work together? I see the relationship. My goal is to use I2C1_SCL routed to port/pin PB8 and I2C1_SDA routed to port/pin PB9. What code do I stuff into the two AFR registers to effect that? Or how about routing I2C1_SCL to PB6 & I2C1_SDA to PB9? Is that possible or are we stuck with what-ever happens to be in the AF04 routing group? In any case, somehow thoe four bits in each AF subgroup route the physical pins to the internal peripherals but I have been unable to determine how that works. Is there a truth table for the specific states listed somewhere? Its probably something too stupid simple for my old brain to figure out!! Any advice is appreciated and thanks in advance, armor #alternate-function-mapping #stm32f42016-08-23 09:03 PM
Each GPIO bank has 16 pins, the AF mux allows for a selection of 16 sources. Each pin has 4-bits assigned to it to select one of these sources.
GPIOx_AFRL & GPIOx_AFRH contain a total of 64-bits, 4x 16 = 64 AFRL handles the AF selections of Pins 0 .. 7 AFRH handles the AF selections of Pin 8 .. 15 GPIOA->ARFL = (GPIOA->ARFL & 0xFFFFFFF0) | 0x00000004; // PA0 to AF4 Think of the AF selection as a Dial Knob with settings 0 to 15, each pin has its own knob. There is a Segger J-Link firmware that can replace the ST-LINK on the NUCELO board.https://www.segger.com/jlink-st-link.html