Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21323 Discussions

Intersting observation regarding flash...

Altera_Forum
Honored Contributor II
1,359 Views

hello i wrote: 

 

//Write to flash int var_2 = FLASH_getIndex(); //////////////////////////////////////////////////////////////////////////////////// LCD_clear(); fprintf(fp_LCD, "%d %d %d\r\n", regions.offset, regions.block_size, var_2); ret_code = alt_write_flash_block(fd_FLASH, 0, regions.offset + (regions.block_size* var_2), FLASH_buffer, BUFF_SIZE); fprintf(fp_LCD, "%d %d %d\r\n", regions.offset, regions.block_size, var_2); while(1) //////////////////////////////////////////////////////////////////////////////////// . the output is: 

65536 65536 0 <-- correct 

 

65536 65536 100663112 <--wrong!!! 

 

why does the var_2 value changes after the alt_write_flash_block function call????
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
462 Views

Could be a memory corruption problem or stack overrun

0 Kudos
Altera_Forum
Honored Contributor II
462 Views

how can i know which one is which...

0 Kudos
Altera_Forum
Honored Contributor II
462 Views

i tested without the function the value of var_2 does not change without the function....

0 Kudos
Altera_Forum
Honored Contributor II
462 Views

memory corruption and stack overflows are the most difficult bugs to track down... If you are using pointers in your code, doublecheck that they are always pointing to what they are supposed to point to. 

Also check that you don't use big structures as local variables in your functions (such as big tables) as it can generate a stack overflow.
0 Kudos
Reply