Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Pointer to timer registers

Altera_Forum
Honored Contributor II
1,112 Views

The following line creates a pointer to a structure used to access a timer: 

 

struct TIMER_REGS *TIMER = (struct TIMER_REGS *)(TIMER_BASE | 0x80000000); 

 

This works when my timer's base address is 0x00000020 

If I change the base address to 0x00000000, it does not work -- meaning code interfacing the structure is not interfacing the timer registers. 

 

I "borowed" this code after finding it in an internet search and I am not understanding the last part. Why is an offset (if that is what it is) being added to the base address? What is the underlying mechanic? 

 

Thanks for your help, 

 

Mike
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
432 Views

The "offset" is just a way to put to 1 the bit 31 of the address. This instructs the CPU to bypass the data cache, as it should when accessing hardware. 

Another way to access the hardware is to include the *_regs.h file provided with the module, and call its IORD_* / IOWR_* macros, instead of using a structure.
0 Kudos
Altera_Forum
Honored Contributor II
432 Views

Thanks Daixwen, 

 

I Called the Altera FAE and he believed the MSB in the address was a cache bypass. 

 

My problem was really me being foolish. I wasn't rebuilding in Quartus after changing in SOPC builder. Duh! 

 

Thanks again.
0 Kudos
Reply