Programming Atmel AT91SAM7S Microcontrollers via USB - Hardware Requirements
Created on: 29 August 2012
AT91SAM7S ARM7 microcontrollers have a built in boot loader program called SAM-BA that allows them to be programmed in-circuit via the USB port without the need for an external programmer.
All that is required is a USB cable and a program (the SAM-BA GUI) from Atmel that runs on the PC.
How the Microcontroller is Programmed via USB
The SAM-BA boot program resides in the AT91SAM7S in ROM. It must be loaded into the first sector of Flash memory so that it will boot when power is switched on. This will overwrite any user program that exists in the Flash memory.
Once the SAM-BA program is loaded to Flash memory, it will be able to communicate with the SAM-BA GUI running on a PC via the USB port. A user program can now be loaded to the microcontroller from the SAM-BA GUI which will overwrite the SAM-BA program in Flash. To load a new user program to the microcontroller, the SAM-BA program must be restored to Flash memory again.
To load SAM-BA to Flash memory, the TST pin of the AT91SAM7S must be pulled high. This will typically be done with a jumper on the microcontroller board. Port pins PA0, PA1 and PA2 must also be pulled high. The board must then be powered up for 10 seconds. After 10 seconds, the board is powered down and the TST pin pulled low - typically by removing the TST pin jumper. This procedure will load (or restore) the SAM-BA program to Flash memory.
The AT91SAM7S can be programmed and re-programmed many times by restoring SAM-BA to Flash memory and then overwriting it with a user program, then restoring it again, etc.
In order for the boot loader to work, there are some hardware requirements that must be met on the microcontroller circuit:
- The USB microcontroller pins must be connected to a USB connector.
- An 18.432 MHz crystal must be used for the microcontroller oscillator to enable a 40MHZ clock for USB operation.
- Pin PIOA16 (PA16) must be dedicated to switching on the USB pull-up resistor - usually through a transistor.
- The TST pin needs to be connected to a jumper to be able to pull it high.
- Pins PA0, PA1 and PA2 must all be pulled high when the TST pin is pulled high.
You can help the Starting Electronics website by making a donation:
Any donation is much appreciated and used to pay the running costs of this website. Click the button below to make a donation.
The state of pins PA0 to PA2 may be affected by externally interfaced hardware. They all need to be high when restoring SAM-BA. If PA0 to PA2 are left unconnected, the default internal pull-up resistors will place a high on these pins.
Pin PA16 must be used to switch a 1k5 pull-up resistor onto the DDP (D+) USB pin. It is possible to leave this pin disconnected or dedicate it to some other use and put a permanent 1k5 pull-up resistor on the DDP pin. It is suggested to do this only if PA16 is required for some other use and the USB port is dedicated to updating the microcontroller software.
The TST pin is pulled low by an internal 15k resistor. It may be preferable to add a stronger external pull-down resistor such as a 4k7 resistor.
The AT91SAM7S-EK evaluation board can be used as a reference design as it is set up to use the USB port for programming. The schematic diagram for this board can be found in the AT91SAM7S-EK Evaluation Board User Guide.
Books that may interest you: