2012-05-13 09:30 AM
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-error2012-05-18 01:22 AM
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.2012-05-20 07:17 AM
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..2012-05-20 07:21 AM
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'');
2012-05-20 10:23 AM
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.2012-05-20 11:46 AM
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_PinSource4void 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);}