Skip to main content
ricardomadera
Associate II
November 16, 2016
Question

STM32F429 Dead alternate function on pin?

  • November 16, 2016
  • 11 replies
  • 2141 views
Posted on November 16, 2016 at 06:42

Hello,

I am trying to configure pins D0-D15 on the STM32F429VIT6 to output sram data. The code seems to be functioning properly and I have scoped out each of the pins however Pin44(PE13)-D10 seems to never go high. Configuring the pin to gpio allows it to toggle on and off. Is it possible to damage  an alternate function on a pin? 

Below is the GPIO init code.

void SRAM_GPIOConfig()

{

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE, ENABLE);

 GPIO_InitTypeDef GPIO_InitStructure;

 /* Common GPIO configuration */

 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

 GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

 /* GPIOD configuration */

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FMC);

 GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FMC);

 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0  | GPIO_Pin_1   |  GPIO_Pin_8  | GPIO_Pin_9  | GPIO_Pin_10 |

                                GPIO_Pin_11 | GPIO_Pin_14 |           GPIO_Pin_15;

  GPIO_Init(GPIOD, &GPIO_InitStructure);

  /* GPIOE configuration */

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource0 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource1 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource3 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource4 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource11 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource12 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource13 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource14 , GPIO_AF_FMC);

  GPIO_PinAFConfig(GPIOE, GPIO_PinSource15 , GPIO_AF_FMC);

  GPIO_InitStructure.GPIO_Pin =

                                GPIO_Pin_7  | GPIO_Pin_8  | GPIO_Pin_9  | GPIO_Pin_10 |

                                GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |

                                GPIO_Pin_15;

  GPIO_Init(GPIOE, &GPIO_InitStructure);

}

    This topic has been closed for replies.

    11 replies

    pohua
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 06:50

    Hi!

    You can refer to the below FMC configuration.

    This code is no problem and use on LCM driver

    PS:I use the STM32F427 MCU.

    static void LCD_GPIO_Config(void)

    {

      GPIO_InitTypeDef GPIO_InitStructure;

      RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE , ENABLE);

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |

                         GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | 

    GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

      GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

      GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

      GPIO_Init(GPIOD, &GPIO_InitStructure);

      /*°t¸mGPIOD¬ÛÀ³ªººÞ¸}´_¥Î³s±µ¨ìFSMC*/

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FMC);    //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D2

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FMC); //°t¸mGPIODªºPin1´_¥Î³s±µ¨ìFSMC D3

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FMC); //°t¸mGPIODªºPin4´_¥Î³s±µ¨ìFSMC nRD

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FMC); //°t¸mGPIODªºPin5´_¥Î³s±µ¨ìFSMC nWR

    //  GPIO_PinAFConfig(GPIOD,GPIO_PinSource6,GPIO_AF_FSMC); //°t¸mGPIODªºPin5´_¥Î³s±µ¨ìFSMC nWAIT

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource7,GPIO_AF_FMC); //°t¸mGPIODªºPin7´_¥Î³s±µ¨ìFSMC  CS

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FMC); //°t¸mGPIODªºPin8´_¥Î³s±µ¨ìFSMC D13

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FMC); //°t¸mGPIODªºPin9´_¥Î³s±µ¨ìFSMC D14

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FMC); //°t¸mGPIODªºPin10´_¥Î³s±µ¨ìFSMC D15

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource11,GPIO_AF_FMC); //°t¸mGPIODªºPin11´_¥Î³s±µ¨ìFSMC A16

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FMC); //°t¸mGPIODªºPin14´_¥Î³s±µ¨ìFSMC D0

      GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FMC); //°t¸mGPIODªºPin15´_¥Î³s±µ¨ìFSMC D1

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |

                     GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

      GPIO_Init(GPIOE, &GPIO_InitStructure);

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D4

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D5

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D6

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D7

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource11 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D8

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource12 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D9

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource13 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D10

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource14 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D11

      GPIO_PinAFConfig(GPIOE, GPIO_PinSource15 , GPIO_AF_FMC); //°t¸mGPIODªºPin0´_¥Î³s±µ¨ìFSMC D12

    }

    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 07:43

    Hi Pohua!

    Thanks for the quick response and the help.

    Here is the FMC code I am using. Any advice would be greatly appreciated.

    Also apologies for the two misleading FSMC names, the structs are indeed FMC.

    #define SRAM_INDEX_ADDR  (*((volatile unsigned short *)0x6F000000))

    #define SRAM_REG_ADDR  (*((volatile unsigned short *)0x6F010000))

    #define SRAM_MEMORY_WIDTH    FMC_NORSRAM_MemoryDataWidth_16b

    #define SRAM_BURSTACCESS    FMC_BurstAccessMode_Disable

    #define SRAM_WRITEBURST    FMC_WriteBurst_Disable

    #define CONTINUOUSCLOCK_FEATURE    FMC_CClock_SyncOnly

    class FMC

    {

    public:

    void Initialize()

    {

    RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE);

    FMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;

    FMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructure;

    /* FSMC Read/Write Timing */

    FSMC_NORSRAMTimingInitStructure.FMC_AddressSetupTime = 5;  /* Address Setup Time  */

    FSMC_NORSRAMTimingInitStructure.FMC_AddressHoldTime = 0;

    FSMC_NORSRAMTimingInitStructure.FMC_DataSetupTime = 5;     /* Data Setup Time */

    FSMC_NORSRAMTimingInitStructure.FMC_BusTurnAroundDuration = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_CLKDivision = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_DataLatency = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_AccessMode = FMC_AccessMode_A; /* FSMC Access Mode */

    FSMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM4;

    FSMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;

    FSMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;

    FSMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_NORSRAM_MemoryDataWidth_16b;

    FSMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;

    FSMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;

    FSMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;

    FSMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;

    FSMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;

    FSMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;

    FSMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;

    FSMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;

    FSMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;

    FSMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;

    FMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

    /* FSMC Write Timing */

    FSMC_NORSRAMTimingInitStructure.FMC_AddressSetupTime = 15;//2;//1;   /* Address Setup Time */

    FSMC_NORSRAMTimingInitStructure.FMC_AddressHoldTime = 0;

    FSMC_NORSRAMTimingInitStructure.FMC_DataSetupTime = 15;//2;//1;     /* Data Setup Time */

    FSMC_NORSRAMTimingInitStructure.FMC_BusTurnAroundDuration = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_CLKDivision = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_DataLatency = 0x00;

    FSMC_NORSRAMTimingInitStructure.FMC_AccessMode = FMC_AccessMode_A; /* FSMC Access Mode */

    FSMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;

    FMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

    /* Enable FSMC Bank4_SRAM Bank */

    FMC_NORSRAMCmd(FMC_Bank1_NORSRAM4, ENABLE);

    }
    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 17:05

    Could this be a hardware issue with the chip itself? Trying to gauge if I should build a second prototype or continue laying the hammer on this code. I find it odd that the pin in GPIO mode works, but not in FMC.

    The reset of the pins output the expected signal when setting the memory locations above.

    waclawek.jan
    Super User
    November 16, 2016
    Posted on November 16, 2016 at 17:43

    How exactly did you observe the ''non-functioning''?

    A short to neighbouring pin/track might be unobservable with a trivial test program if the other signal is inactive. Oscilloscope might reveal suspicious voltage levels in that case.

    Also, disconnected pin migh seem to work when measured direcly on pin, and not working when measured at the track/target devices' pin.

    JW
    Tesla DeLorean
    Guru
    November 16, 2016
    Posted on November 16, 2016 at 17:52

    Could this be a hardware issue with the chip itself? 

    This honestly is the least likely reason. You'd need to review the board and the netlist. Make sure there are no shorts, either at the STM32 end or the SRAM end. Review an unpopulated board. Review a board with just the STM32.

    If you think it is this chip, unsolder and replace with another.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 17:53

    Hi waclawek.jan,

    Thanks for your response!

    I observed this using my scope and measuring the individual pins. I also metered the circuit board and the trace is not shorted with neighbors and reads a good connection to its pin PE10. Only when this pin is configured as FMC does it not respond. As a GPIO it works correctly.

    Measuring the pin directly also reads logic low when in FMC mode. 

    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 18:08

    Hi clive1,

    Thank you so much for your support. Your collection of threads have been super useful in my developments.

    I did verify that the board is intact with proper connections and no shorts. I also checked the netlist on schematics, the trace on my pcb design, and then finally verified with the gerbers i sent out.

    Let me add that I am using FMC to read and write to D0-D15 for interfacing with a smart TFT panel, so I have been developing mostly with a scope and a logic analyzer.

    On Friday I receive the parts to build another prototype to try and replicate the issue.

    In the meantime, is there anything else I should do to debug further? Perhaps its a bug with the StdPeriph lib i am using?

    waclawek.jan
    Super User
    November 16, 2016
    Posted on November 16, 2016 at 18:23

    Read back the content of relevant registers (GPIO in this case) and check.

    Make sure the test program really exercises D10.

    Try to disconnect the load.

    JW

    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 18:26

    I will double check the GPIO registers this today. I did verify that in GPIO mode it toggles up and down correctly with no load. 

    ricardomadera
    Associate II
    November 16, 2016
    Posted on November 16, 2016 at 23:32

    Ok, with the load disconnected, checked the GPIOD & E registers and they are setup correctly. I also ported the same code to the F4Disco board and it worked on all pins. I am a bit clueless as to whats going on now if a hardware issue is very unlikely. I am using the Periph v1.2 library on both targets.