cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use the cube_lib

ajacquet
Associate
Posted on March 05, 2015 at 18:25

Hello all,

Wondering if anyone figured out how to use the sram  (stm32f4xx_hal_sram.h) setup to output to various displays .. Having trouble with writing straight to an address port ..

With all the ports set up in the gpio under the void HAL_FMC_MspInit(void)..

I'm using the StCubeMx program to set things up with ...

This is in the alj_port_write.c file:

I'm calling the alj_portwrite(); from another c file

&sharpinclude <stm32f4xx_hal_conf.h>

&sharpinclude ''includes.h''

&sharpdefine adport  0x6C000000

GPIO_InitTypeDef  GPIO_InitStructure;

int i;

void alj_portwrite(void)

{

    //  Even though this is in another c file and being called I put this here trying to

    //  make since of what is going on 

     

   /*Perform the SRAM4 memory initialization sequence*/

     SRAM_HandleTypeDef hsram4;

     FMC_NORSRAM_TimingTypeDef Timing;

      hsram4.Instance = FMC_NORSRAM_DEVICE;

      hsram4.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

      /* hsram4.Init */

      hsram4.Init.NSBank = FMC_NORSRAM_BANK4;

      hsram4.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;

      hsram4.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;

      hsram4.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;

      hsram4.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;

      hsram4.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;

      hsram4.Init.WrapMode = FMC_WRAP_MODE_DISABLE;

      hsram4.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;

      hsram4.Init.WriteOperation = FMC_WRITE_OPERATION_DISABLE;

      hsram4.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;

      hsram4.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;

      hsram4.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE;

      hsram4.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;

      hsram4.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;

      /* Timing */

      Timing.AddressSetupTime = 15;

      Timing.AddressHoldTime = 15;

      Timing.DataSetupTime = 255;

      Timing.BusTurnAroundDuration = 15;

      Timing.CLKDivision = 16;

      Timing.DataLatency = 17;

      Timing.AccessMode = FMC_ACCESS_MODE_A;

      /* ExtTiming */

      HAL_SRAM_Init(&hsram4, &Timing, NULL);

    __GPIOA_CLK_ENABLE();

    __GPIOB_CLK_ENABLE();

    __GPIOC_CLK_ENABLE();

    __GPIOD_CLK_ENABLE();

    __GPIOE_CLK_ENABLE();

    __GPIOF_CLK_ENABLE();

    __GPIOG_CLK_ENABLE();

// end of the mem setup which is in another c file

//    __FMC_CLK_ENABLE();

// this is in the void HAL_FMC_MspInit(void)  also uncommenting this will kill the port

      ///Diag Leds

      GPIO_InitStructure.Pin   =  GPIO_PIN_6;

      GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;

      GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;

      HAL_GPIO_Init(GPIOF, &GPIO_InitStructure);

      GPIO_InitStructure.Pin =  GPIO_PIN_1;

      HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

//    SRAM_HandleTypeDef hsram;

//    hsram.Instance = FMC_NORSRAM_DEVICE;

//    hsram.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

// no setup for which bank in the SRAM_HandleTypeDef function

//    HAL_SRAM_StateTypeDef ret;

    &sharpdefine ARRAY_SIZE   2

    uint16_t buf1[ARRAY_SIZE];

    buf1[1] = 0X55;   // Bytes can be sent while the leds are being toggle

    buf1[2] = 0xAA; // As I found out you can't send 16 bit stuff

    for(;;)

    {

        for ( i = 0 ; i < 20000 ; i++ ) { }

        *(WORD *)adport = buf1[1];

        for ( i = 0 ; i < 20000 ; i++ ) { }

        *(WORD *)adport = buf1[2];

// have tried using

//ret= HAL_SRAM_Write_16b(&hsram, adport, buf1 , ARRAY_SIZE); 

// but have no understanding of the setup yet as it complains about a casting error

         for ( i = 0 ; i < 20000 ; i++ ) { }

// As I found out commenting these out will result with the address port not working 

                                 HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_6);

                                 HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_1);

// Something about toggling the IO ports causes the address ports to work for a brief

// period

    }

}

#stm32f429 #stm32 #cubemx #sdram
0 REPLIES 0