cancel
Showing results for 
Search instead for 
Did you mean: 

Out of memory?

hitsumen
Associate II
Posted on May 13, 2012 at 18:30

Good day,

I was playing with ST32F103RET6 MCU.

I looked in datasheet, my MCU has 64Kb of SRAM, so I could easily create array with 20 kbytes. But I cannot.

I use IAR compiler, What can be wrong. I can create only 1800byte array.

unsigned char my_array[1800];

If I create something like my_array[3000]. My MCU going to reset..

Thank you.

#ram #linker-error
14 REPLIES 14
frankmeyer9
Associate II
Posted on May 18, 2012 at 10:22

Do you access this array from two different places, say, from main loop and from within an interrupt ?

Then you might have a synchronization problem. The pictures look like something is advancing your array indices 'randomly' in the loop, judging the code you provided.

hitsumen
Associate II
Posted on May 20, 2012 at 16:17

Its weird, I removed transfer to UART, and changed to transfer directly to LCD and it worked, hmm, but still something is not right.. I think something is wrong with interupts.. I will post my interupt functions when I get home, maybe you will find something strange there.

I think that when I do some processing, interupt handler could interupt the sending process, and something weird is happening..

hitsumen
Associate II
Posted on May 20, 2012 at 16:21

Yes I think the same thing.. I will post some code, maybe you see what is wrong here.. And I tried to disable global interupts, it does not worked, it looked something like this:

asm volatile (''cpsid i'');
frankmeyer9
Associate II
Posted on May 20, 2012 at 19:23

I guess your ''threads'' (to steal this terminus from PC programming) are not properly synchronized. Interrupts, especially communication related ones, have a lot in common with threads/processes. The synchronization and safe communication between those threads is a nontrivial problem - I believe you know those issues like race conditions & deadlocks...

If you have a logic analyzer available, you can use some free GPIOs as debug outputs to trace the issue down under realtime conditions.

hitsumen
Associate II
Posted on May 20, 2012 at 20:46

some code:

#define GPIO_VSYNC_CMOS                    GPIOC

#define RCC_APB2Periph_GPIO_VSYNC_CMOS     RCC_APB2Periph_GPIOC

#define GPIO_PIN_VSYNC_CMOS                GPIO_Pin_4

#define EXTI_LINE_VSYNC_CMOS               EXTI_Line4

#define GPIO_PORT_SOURCE_VSYNC_CMOS        GPIO_PortSourceGPIOC

#define GPIO_PIN_SOURCE_VSYNC_CMOS         GPIO_PinSource4

void ov7670_Interrupts_Config_EN(void)

{

  NVIC_InitTypeDef NVIC_InitStructure;

  

#ifdef  VECT_TAB_RAM  

  /* Set the Vector Table base location at 0x20000000 */ 

  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 

#else  /* VECT_TAB_FLASH  */

  /* Set the Vector Table base location at 0x08000000 */ 

  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   

#endif

  /* Configure one bit for preemption priority */

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

  

    /* Configure one bit for preemption priority */

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  

  /* Enable the EXTI9_5 Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

void OV7670_EXTI_Config_EN(void)

{

  EXTI_InitTypeDef EXTI_InitStructure;

  GPIO_EXTILineConfig(GPIO_PORT_SOURCE_VSYNC_CMOS, GPIO_PIN_SOURCE_VSYNC_CMOS);

  EXTI_InitStructure.EXTI_Line = EXTI_LINE_VSYNC_CMOS;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising ;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  EXTI_GenerateSWInterrupt(EXTI_LINE_VSYNC_CMOS);

}