STM32F429 + external SDRAM

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

Moderators: RoccoMarco, barthess

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

STM32F429 + external SDRAM

Postby Skadi » Fri Apr 17, 2015 5:22 pm

Hi,

I'm trying to access an external RAM and did it according to http://www.chibios.org/dokuwiki/doku.php?id=chibios:community:plans:external_ram. Unfortunately I get the following warning: implicit declaration of function 'chHeapInit' [-Wimplicit-function-declaration].

My code is following below and has no further task. I'm just trying to compile the code.

Code: Select all

#include "ch.h"
#include "hal.h"

#include "extSDRAM.h"

static void fmc_setup(void) {
    unsigned char FMC_Bank;

    // STM32F4 FMC init
    rccEnableAHB3(RCC_AHB3ENR_FMCEN, 0);

    // Group pins
    IOBus busB = {GPIOB, (1 << 5) | (1 << 6), 0};
    IOBus busC = {GPIOC, (1 << 0), 0};
    IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 14) | (1 <<  15), 0};
    IOBus busE = {GPIOE, (1 << 0) | (1 << 1) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15), 0};
    IOBus busF = {GPIOF, (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 11) | (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15), 0};
    IOBus busG = {GPIOG, (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 8) | (1 << 15), 0};

    // FMC is an alternate function 12 (AF12)
    palSetBusMode(&busB, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busC, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busF, PAL_MODE_ALTERNATE(12));
    palSetBusMode(&busG, PAL_MODE_ALTERNATE(12));

        // The SDRAM is connected to the first FMC BANK (NE1)
    FMC_Bank = 0;

    // FMC timing. Use BTRx where x is the sub-bank.
    FMC_Bank1->BTCR[FMC_Bank+1] = (FMC_BTR1_ADDSET_1 | FMC_BTR1_ADDSET_3) | (FMC_BTR1_DATAST_1 | FMC_BTR1_DATAST_3) | (FMC_BTR1_BUSTURN_1 | FMC_BTR1_BUSTURN_3);

    // Bank1 NOR/SRAM control register configuration. Use BCRx where x is the sub-bank.
    FMC_Bank1->BTCR[FMC_Bank] = FMC_BCR1_MWID_0 | FMC_BCR1_WREN | FMC_BCR1_MBKEN;

}


msg_t extSDRAM(void *p) {

  fmc_setup();

  static MemoryHeap ext_heap;
  static uint16_t *buffer;

  uint32_t RAMsize = 67108864;   // 512 Mbit = 67108864 Byte

  chHeapInit(&ext_heap, (void*)0x60000000,  RAMsize);
  buffer = chHeapAlloc(&ext_heap, 67108864);


    (void)p;

    while(1){
                  // nothing at the moment
            }

    return RDY_OK;
}



Maybe someone can tell me what I'm missing to avoid the warning.

greets

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F429 + external SDRAM

Postby Giovanni » Fri Apr 17, 2015 5:28 pm

Hi,

Probably you are using 3.0, chHeapInit() has been renamed to chHeapObjectInit() for consistency with all other object initializers.

Giovanni

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32F429 + external SDRAM

Postby Tectu » Sat Apr 18, 2015 11:34 am

The guide you linked was written for the FSMC interface and SRAM. The SDRAM is connected to the newer FMC interface. The code might be very different.


~ Tectu

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32F429 + external SDRAM

Postby Skadi » Mon Apr 20, 2015 8:29 am

Hi,

thanks for your replays.

@ Giovanni: I'm using 2.6.7, thus the command shouldn't be the problem.

@ Tectu: The code is already adapted for FMC but i don't know if larger changes are necessary. I haven't found any example code for SDRAM.

greets

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F429 + external SDRAM

Postby Giovanni » Mon Apr 20, 2015 8:38 am

Make sure that:

CH_USE_HEAP is set to TRUE
CH_USE_MALLOC_HEAP is set to FALSE

Giovanni

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32F429 + external SDRAM

Postby Skadi » Mon Apr 20, 2015 8:51 am

Hi, Giovanni.

CH_USE_MALLOC_HEAP was set TRUE. I thought that is necessary to use chHeap.

Now I can compile the code without a warning!!!

Thank you very much!!!

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32F429 + external SDRAM

Postby Tectu » Mon Apr 20, 2015 9:29 am

Please let us know when you get it working and if possible provide a very minimalistic setup and usage example.


~ Tectu

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32F429 + external SDRAM

Postby Skadi » Mon Apr 20, 2015 3:02 pm

Hi,

if I manage to write a code that works, I will share it.

But I have still troubles. I tested SDCLK whit an oscilloscope, which should be enabled at pin PG8, but no clock signal occures. SDCLK should be started by enabeling AHB3

Code: Select all

rccEnableAHB3(RCC_AHB3ENR_FMCEN, 0);


So it seems i miss a couple of parameters which are necessary to get the system working. Is there any example code or instruction available? I haven't found any code that fits for me.

greets

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F429 + external SDRAM

Postby Giovanni » Mon Apr 20, 2015 6:03 pm

Hi,

The first parameter is defined into the ST header, the second parameter is a boolean indicating if the peripheral clock should be active during sleep states.

Giovanni

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32F429 + external SDRAM

Postby Skadi » Tue Apr 21, 2015 9:02 am

Hi Giovanni,

I think the clock on the AHB3 bus should be enabled with this command, according to the comment in stm32_rcc.h on line 214 (@brief Enables the clock of one or more peripheral on the AHB3 (FSMC) bus.). By using RCC_AHB3ENR_FMCEN as first command the corresponding value is set 1 and the clock should start.

Do I have to enable the AHB bus or FMC somewhere? I don't get any warnings or errors.

Skadi


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 19 guests