Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

AT32UC3A0512 with external SDRAM not working

Posted by adissida on September 8, 2015

Hi! New with FreeRTOS, and so far it is impressive! Love it. Now I want to make use of the external SDRAM. I have a rutine that check the SDRAM and it works grate when using heap3. I have also two leds blinking independently different freq. So freertos works grate. Now I add heap5 and define the SDRAM start and size (0x7A12000, 16MB of SDRAM):

'#include "FreeRTOS.h" '#include "task.h"

int main (void) { const HeapRegiont xHeapRegions[] = { { ( uint8t * ) 0xD0000000UL, 0x7A12000 }, { NULL, 0 } }; void vPortDefineHeapRegions(xHeapRegions);

trvInitHercules();

xTaskCreate( trvBlinkMCULED,		(const signed portCHAR *)"Blink MCU",	configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY1, NULL );
xTaskCreate( trvBlinkAlarmLED,		(const signed portCHAR *)"Blink Alarm", configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY2, NULL );

vTaskStartScheduler();

return 0;

}

The memory test in trvInit() passes, and then should leds start blinking, but no. I have followed all instructions that I found regardingn external SDRAM. What could be wrong?


AT32UC3A0512 with external SDRAM not working

Posted by heinbali01 on September 9, 2015

Hi Adis,

Using Atmel's UC3A0512 :

{ ( uint8_t * ) 0xD0000000UL, 0x7A12000 },

My calculator says that '0x7A12000' equals 128000000, which is about 122 MB. Accessing non-existent memory might lead to a crash (hardware exception). You write that you have 16MB of SDRAM, which corresponds to 0x1000000.

The heap regions are described in an array of:

~~~~~ /* Used by heap5.c. */ typedef struct HeapRegion { uint8t *pucStartAddress; sizet xSizeInBytes; } HeapRegiont;

~~~~~

You could write it like this:

~~~~~

incluide

/* which includes "uc3a0512.h" with this declaration:

define AVR32EBICS1_ADDRESS 0xD0000000

*/

define SDRAMADDRESS ( AVR32EBICS1ADDRESS )
define SDRAM_SIZE ( 16ul * 1024 * 1024 )

/* * What is the clock speed of your CPU: 48, 60 or 66 MHz ? * The HSB (High-Speed-Bus) is equal to the CPU speed, * they're coupled. */

define CLOCKHSBHZ 48000000

const HeapRegiont xHeapRegions[] = { { ( uint8t * ) SDRAMADDRESS, ( sizet ) SDRAMSIZE }, { ( uint8t * ) NULL, ( size_t ) 0 } };

/* or if you like, a less-used C syntax: */

const HeapRegiont xHeapRegions[] = { [0] = { .pucStartAddress = ( uint8t * ) SDRAMADDRESS, .xSizeInBytes = ( sizet ) SDRAMSIZE }, [1] = { .pucStartAddress = ( uint8t * ) NULL, .xSizeInBytes = ( size_t ) 0 } };

void main() { /* Initialise the SDRAM. / / See "EBI/SDRAMC/sdramc.c" */ sdramcinit( CLOCKHSB_HZ );

/* Tell heap_5 which heap area(s) can be used. */
vPortDefineHeapRegions( xHeapRegions );

/* Your code: */
trvInitHercules();

/* The string "Blink MCU" doesn't need a cast to
because now xTaskCreate() takes a const char* */
xTaskCreate( trvBlinkMCULED, "Blink MCU", configMINIMAL_STACK_SIZE,
    NULL, mainLED_TASK_PRIORITY1, NULL );
xTaskCreate( trvBlinkAlarmLED, "Blink Alarm", configMINIMAL_STACK_SIZE,
    NULL, mainLED_TASK_PRIORITY2, NULL );

vTaskStartScheduler();

}

~~~~~

Will that work?

Regards.


AT32UC3A0512 with external SDRAM not working

Posted by adissida on September 9, 2015

Hi

Nope, still dead. This is what my main.c contais now:


'#include '#include '#include '#include '#include

'#include "gpio.h" '#include "trv_apps.h"

'#define SDRAMADDRESS AVR32EBICS1ADDRESS '#define SDRAMSIZEA ( 16ul * 1024 * 1024 )

'#include "FreeRTOS.h" '#include "task.h"

const HeapRegiont xHeapRegions[] = { { ( uint8t * ) SDRAMADDRESS, ( sizet ) SDRAMSIZEA }, { NULL, ( size_t ) 0 } };

int main (void) { trvInitHercules();

void vPortDefineHeapRegions(xHeapRegions);

xTaskCreate( trvBlinkMCULED, "Blink MCU",	configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY1, NULL );
xTaskCreate( trvBlinkAlarmLED, "Blink Alarm", configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY2, NULL );

vTaskStartScheduler();

return 0;

}


and this is where my trvInitHercules(); is:


'#include '#include '#include '#include '#include

'#include "gpio.h" '#include "sdramc.h" '#include "trvapps.h" '#include "powerclocks_lib.h"

'#include "FreeRTOS.h" '#include "task.h"

volatile unsigned long *sdram = SDRAM; volatile unsigned long *sdram_work = SDRAM;

void trvInitHercules(void) { /* This function is meant to contain board-specific initialization code * for, e.g., the I/O pins. The initialization can rely on application- * specific board configuration, found in conf_board.h. */

pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);

static pcl_freq_param_t pcl_freq_param =
{
	.cpu_f        = 66000000,
	.pba_f        = 66000000,
	.osc0_f       = FOSC0,
	.osc0_startup = OSC0_STARTUP
};

// Configure system clock
if (pcl_configure_clocks(&pcl_freq_param) != PASS)
{
	gpio_clr_gpio_pin(HER_LED_MCU);
}

sdramc_init(F_CPU); // F_CPU is 66000000

//trvSDRAMSelfTest(sdram);

}


Dont know why it doeset work.


AT32UC3A0512 with external SDRAM not working

Posted by adissida on September 9, 2015

My fault, i entered void vPortDefineHeapRegions(xHeapRegions); instead of just vPortDefineHeapRegions(xHeapRegions);.... Now it works. Thank you Hein!


AT32UC3A0512 with external SDRAM not working

Posted by heinbali01 on September 10, 2015

I already looked at your:

~~~~~ main() { void vPortDefineHeapRegions(xHeapRegions); } ~~~~~

and I wondered how the compiler would interpret that line.

It is not a function call because of the word "void". It is not a function declaration because it misses a parameter type.

Now it works. Thank you Hein!

If you have any more questions, don't hesitate to write.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS