Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

7.5.3.2.1. Locating Functions in Tightly Coupled Memory

Assigning data to a tightly coupled data memory also involves using a section attribute. Alternatively, you can include the tightly coupled memory as a #define in the system.h file. The name of the memory is followed by _BASE and is used as a pointer to reference the tightly coupled data memory.

The software example in this tutorial provides a source code example showing how to locate a particular source code function in a particular linker section. A function is declared to reside within a linker section with the C section attribute in the file timer_interrupt_latency.h. This C header file locates timer_interrupt_latency_irq() in the .exceptions section as follows:

externvoid timer_interrupt_latency_irq (void* base, alt_u32 id)__attribute__ ((section
(".exceptions")));

The Nios® II Software Build Tools (SBT) creates linker sections for each memory module in the system. A source code function can be located within a particular tightly coupled instruction memory simply by assigning that function to the linker section created for that tightly coupled instruction memory.

The Nios® II SBT creates additional linker sections with address mappings that are controlled by Platform Designer. For the .exceptions section, the physical address offset and memory module in which to base that linker section is manipulated through Platform Designer. You locate the .exceptions section in a memory module covered by a tightly coupled data memory using the Exception Vector field found on the Core Nios® II tab of the configuration wizard.

For more information about the C section attribute, refer to the Developing Programs Using the Hardware Abstraction Layer chapter in the Nios® II Software Developer’s Handbook.