hal_lld_init resets FSMC!

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

hal_lld_init resets FSMC!

Post by alexblack »

Hi.
I used STM32F407 mcu with external SRAM memory connected on FSMC.
I initialized FSMC in board.c file before the C enviroment setup:

Code: Select all

void __early_init(void)
{
  stm32_clock_init();

  #ifdef FSMC_USED

  // CLOCK the peripheral
  #if defined(STM32F10X_HD)
  RCC->AHBENR |= RCC_AHBENR_FSMCEN;
  #elif defined(STM32F4XX)
  RCC->AHB3ENR |= RCC_AHB3ENR_FSMCEN;
  #else
  #error "Not supported device!"
  #endif

  // SETUP FSMC to work correctly
  FSMC_Bank1->BTCR[0] = FSMC_BCR1_WREN | FSMC_BCR1_MWID_0 | FSMC_BCR1_MBKEN; // FSMC_BCR1 register
  FSMC_Bank1->BTCR[1] = FSMC_BTR1_DATAST_1 | FSMC_BTR1_DATAST_0;             // FSMC_BTR1 register
  #endif
}

But in hal_lld.c the FSMC resets:

Code: Select all

 file 'os\hal\platforms\STM32F4xx\hal_lld.c'
...
89 /**
90  * @brief   Low level HAL driver initialization.
91  *
92  * @notapi
93  */
94 void hal_lld_init(void) {
95
96   /* Reset of all peripherals. AHB3 is not reseted because it could have
97      been initialized in the board initialization file (board.c).*/
98   rccResetAHB1(~0);
98   rccResetAHB2(~0);
99   rccResetAHB3(~0);
100 rccResetAPB1(~RCC_APB1RSTR_PWRRST);
101 rccResetAPB2(~0);

The comments says that AHB3 not resets (FSMC on it) but code do that. Need to remove 'rccResetAHB3(~0);' or mask FSMC to not reset.
p.s. On STM32F103 there is no such problem.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: hal_lld_init resets FSMC!

Post by Giovanni »

Hi,

Could you open a ticked about thins? the fix is simple. As temporary workaround you could move the initialization after calling halInit().

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: hal_lld_init resets FSMC!

Post by alexblack »

Hi.
Giovanni wrote:Could you open a ticked about thins? the fix is simple.
As temporary workaround you could move the initialization after calling halInit().
Giovanni

No, i do not know how to open ticket, sorry.
I understand that the fix is simple and I wroted this topic to inform about it.
Initializion of external RAM after halInit is not good because segment initializion procedure of C startup will fail and static variables declared in this area will contaion not valid init data.
As temporary workaround I simple remove reset line from hal_lld_init function :). Moreover at this moment I have no projects on STM32F407, I used it only for testing.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: hal_lld_init resets FSMC!

Post by Giovanni »

No problem, I will open it.

It is this place anyway: http://sourceforge.net/p/chibios/bugs/?source=navbar :)

Giovanni
Post Reply