Forum Discussion
Altera_Forum
Honored Contributor
15 years agoAlternatively define a C struct that maps your device registers.
Define an 'extern' variable of that type. Use the linker to place the variable at the correct address - setting the high address bit if you have the data cache enabled. You either need to make the structure members 'volatile', or put 'asm volatile("" ::: "memory")' in the C source at appropriate points to ensure gcc doesn't have any values cached in registers. Note that gcc generates additional instrctions for 8 and 16 bit volatile data.