![](images/atmel.png)
Atmel AT91SAM9 CPU Support Package
This package contains project templates and system files for the Atmel AT91SAM9.
CrossWorks Version 3 Installation Instructions
This package can only be installed if you have the following CrossWorks license bolt-ons:
- ARM License
- To install this support package
-
- Click the Tools > Package Manager menu option to open the package manager window.
- Right click on the Atmel AT91SAM9 CPU Support Package entry and select Install Selected Packages.
- Click Next to take you to the summary page.
- Click Next to install the package.
- Click Finish to close the package manager window.
- Click the Tools > Show Installed Packages.
- Click on the Atmel AT91SAM9 CPU Support Package link to view the package and its contents.
- To manually install this support package
-
- If you have not done so already, follow the CrossWorks Tasking Library Package installation instructions.
- Download the file AT91SAM9.hzq using your web browser.
- Click the Tools > Manually Install Packages menu option.
- Select the file you have just downloaded to install the package.
- Click the Tools > Show Installed Packages.
- Click on the Atmel AT91SAM9 CPU Support Package link to view the package and its contents.
- To install this support package using other versions
Release Notes
2.5
- Added support for AT91SAM9CN11, AT91SAM9CN12 and AT91SAM9N12 devices.
2.4
- Added support for AT91SAM9X25, AT91SAM9X35, AT91SAM9G15, AT91SAM9G25 and AT91SAM9G35 devices.
- Added SPIFlash loader source files.
2.3
- The start address of the memory shadowed by the DataFlash loader can be specified in the Target Loader Options | Loader Parameter property.
- Fixed verify in the DataFlash loader.
- The DataFlash loader can now support multiple programs. Note that they need to be loaded in ascending address order.
2.2
- Added support for AT91SAM9G10 and AT91SAM9G45 devices.
- Fixed bitfield descriptions of PWM interrupt registers in memory maps and header files.
2.1
- Reduced the JTAG frequency in the reset script after main oscillator is selected.
- The SAM9XE flash loader has the libmem_crc symbol to enable fast verification.
2.0
- Initial Release.
Documentation
Creating AT91SAM9 Projects
To create a new AT91SAM9 project
- Select the File > New > New Project menu item.
- Select the appropriate Generic AT91SAM9 from the Categories list.
- Select the required project template type from the Templates list.
- Set the required project name and location directory.
- Click OK.
To build and debug an application
- Select the project to work on by using the Project > Set Active Project menu option.
- Select the configuration you require by using the Build > Set Active Build Configuration menu option.
- Build the project by using the Build > Build Project menu option.
- Connect to the appropriate target in the target window.
- Download and start debugging the current project by using Debug > Start Debugging.
For a SAM9XE device the project will be built to run in internal flash. For a SAM9 device the project will be build to run in internal SRAM. If you wish to run from internal SRAM on a SAM9XE device then you should right click on the project node in the project explorer and select the ISRAM placement.
AT91SAM9 Project Specifics
Target Processor
There are two sets of target processors supported, Atmel AT91SAM9 and Atmel AT91SAM9XE. Once a project has been created you can select different target processors from the selected set by right clicking on the project node in the project explorer and selecting the Target Processor entry.
Selecting the target processor will specify the memory map that is used for the build and debug. You can view the selected memory map by right clicking on the project node in the project explorer and selecting View Memory Map or View Memory Map (as text). In the memory map files the memory segments defining the names, sizes and access types of the external memories are specified using macros which can be set using the Memory Map Macros project property. Similarly for memory map files that have TCM's the desired sizes of the TCM's can be specified.
Section Placement
CrossStudio for ARM supports AT91SAM9 projects running applications in a number of different memory configurations. You can select the memory configuration you require by right clicking on the project node in the project explorer and selecting the Placement entry.
For AT91SAM9 projects the set of placements are:
- ISRAM application runs in internal SRAM.
- SDRAM application runs in SDRAM and can be loaded from DataFlash.
- SDRAM_TCM application runs in SDRAM and TCM and can be loaded from DataFlash.
- FLASH application runs in NOR Flash with data in SDRAM.
- FLASH_TCM application runs in NOR Flash and TCM with data in SDRAM and TCM.
For AT91SAM9XE project the set of placements are:
- IFLASH application runs in internal NOR Flash.
- ISRAM application runs in internal SRAM.
- SDRAM application runs in SDRAM.
Placement files that use SDRAM will allocate the first 16K of SDRAM for the MMU translation table. The internal NOR Flash placement file puts the MMU translation table into the internal NOR Flash. The internal SRAM placement file doesn't allocate an MMU translation table. All placement files use internal SRAM for the exception vectors.
Debug Handler
When you create a AT91SAM9 project a file is included in the build that implements additional (to JTAG) debug functionality. This file is used to implement monitor mode debug. This enables interrupts to occur when stopped on a breakpoint and memory to be examined without stopping the processor. The project setup code creates a debug project property Debug Handler that enables you to choose additional (to JTAG) debug capabilities you require:
- None don't use the debug handler for breakpoints.
- Halt Mode use the debug handler but don't allow interrupts to execute on breakpoint.
- Monitor Mode Memory same as halt mode but memory access is done using the debug handler. To use this your application will have to periodically call the function dbg_poll()
- Monitor Mode full monitor mode debug.
Target Startup Code
The startup code AT91SAM9_Startup.s is common to all AT91SAM9 processors there are a set of preprocessor defines that configure the startup code and are documented in the startup file itself.
Target Reset Script
There are two reset scripts one for AT91SAM9_Target.js devices and one for AT91SAM9XE_Target.js devices. The reset script for the AT91SAM9XE enables the GPNVM bits to be displayed and programmed using the right click menu on the connected target in the Targets
AT91SAM9XE Internal Flash Loader
The flash loader
for the internal NOR Flash of A91SAM9XE is provided. Source files to build flash loaders for external NOR Flash and DataFlash are provided which are used by the various AT91SAM9 board support packages.AT91SAM9 DataFlash/SPIFlash Loader Files
The DataFlash/SPIFlash loaders are board specific, however the files that are common to all DataFlash/SPIFlash loaders are supplied in the AT91SAM9 CPU support package. The DataFlash/SPIFlash loader works by shadowing memory writes to the SDRAM section into the DataFlash/SPIFlash. You can specify the start address of memory to shadow in the Target Loader Options | Loader Parameter property. The DataFlash/SPIFlash loader adds the secondary boot loader to the start of the DataFlash/SPIFlash. Before it is written the secondary boot loader is updated with the start address the DataFlash/SPIFlash is copied to (and ultimately starts executing at) and the number of bytes to copy based on the highest shadowed address.
- spi0df.c DataFlash functions for SPI0 peripheral.
- spi0sf.c SPIFlash functions for SPI0 peripheral.
- dataflash_loader.c the DataFlash loader.
- spiflash_loader.c the SPIFlash loader.
- sb_loader.c the DataFlash secondary boot loader.
- sb_loader.c the SPIFlash secondary boot loader.
- sbloader.s the binary image of the secondary boot loader.
- Secondary_Loader_MemoryMap.xml the secondary boot loader memory map and placement.
- Secondary_Loader_Startup.s reduced startup code for the secondary boot loader.
Memory Simulator
An AT91SAM9 memory simulator is provided that simulates the memories of the various AT91SAM9 devices. The memory simulation parameter (which is set by the Target Processor selection) contains macros that determine the sizes of the simulated memories and can be specified using the Memory Simulation Parameter Macros property.
Interrupt Handling
The file AIC.c implements the ctl_set_isr, ctl_unmask_isr and ctl_mask_isr functions by programming the AIC register group. The vector parameter to these functions corresponds to the peripheral identifier as defined in the appropriate device user manual. The priority parameter to the ctl_set_isr is between 0 and 7 then an ARM IRQ exception is generated. If nested interrupts are enabled on the irq_handler then the priority is a pre-emption priority i.e. interrupt handlers can be interrupted by higher priority interrupt handlers. If the priority parameter to the function ctl_set_isr is 8 then an ARM FIQ exception is generated. The file AIC_irq_handler.s implement the irq_handler and fiq_handler exception handlers.
Header Files
Header files are generated from the memory map files and can be included using the file AT91SAM9.h. The AT91SAM9 project setup adds the directory $(TargetsDir)/AT91SAM9 to the User Include Directories project property so that you can just include targets/AT91SAM9.h into your source code.
CrossWorks Sample Projects
The following project files are supplied that can be used to run the standard CrossWorks samples.
- AT91SAM9 Shared Samples (click to load project)
- AT91SAM9XE Shared Samples (click to load project)