Music player built on microcontroller AT91SAM7S256 with ARM core

Szymon Dyja

1. The player allows:

  • playback wav files in stereo format, 22,500Hz freqfency, and 8 bits of resolution,
  • display the song titles,
  • display time of songs,
  • the possibility of stopping (pause) and switch songs,
  • the possibility of change volume (+, -),
  • read data from the MMC memory card inserted in the slot,
  • display current state on the alphanumeric LCD display,
  • the possibility set random order of songs

Music player on AT91SAM7S256

2. For the construction this system could be executed the following elements:

  • microcontroller AT91SAM7S256 from Atmel,
  • alphanumeric LCD display with HD44780 driver ,
  • keyboard with 4 buttons ,
  • memory-card slot,
  • memory card MultimediaMemory Stick (MMC) or optional SD card

Schematic Diagram

Schematic diagram: Music player on AT91SAM7S256
Click to enlarge

3. The principle of operation is quite simple.

a) data from the memory card
          | SPI
b) uC SAM7S
          | PWM
c) AUX

Ad. a) data from the memory card are reading by the module FatFS. It is necessery bacause on card is used FAT16, FAT32 format. We can playback a wav files, witch are stored on memory card. To store it you can use your PC. Read data are stored up to 2 buffers - it is required because the data may not interfere with the currently playing music.

FatFs module has been written in ANSI C, so it's independent from the hardware layer and can be easily transferred to different types of microprocessors. Support for the card via the SPI is held by only 3 pins of the microprocessor - lines of data MISO, MOSI, and the clock CLK line. The card requires a power supply voltage of 3.3V, which is equal to the voltage of power processor SAM7S.

Ad. b) In microcontroller timer PIT is set to submit periodic interrupt reqest 22.5 kHz frequency - the frequency of sampling music files. The interrupt checking which data buffer is currently being used and the appropriate values of indexes are transmitted to the buffer registers PWM generator. These values representing 2 channels of sound (left and right). When the index of buffer reach the maximum length of the array the current buffer change, and the flag is set - to allow to write of the next portion data to another buffer.

Ad. c) The player uses 2 independent PWM channels, which are configured to work with a resolution of 8 bits, and the frequency of MCK / 8. The filling PWM generator is dependent on the data collected from the buffer, and is proportional to the voltage output corresponding to the I/O pin of the microcontroller.

The data are processing by uC AT91SAM7S256. It is a 32-bit architecture RISC processor type. SAM7S with ARM ARM7TDMI is one of most successful model.

Some features of SAM7S256:

  • Internal High-speed Flash - 256 Kbytes Organized in 1024 Pages of 256 Bytes
  • Internal High-speed SRAM - 64 Kbytes
  • Reset Controller
  • AIC- Advanced Interrupt Controller
  • DBGU, 2-wire UART, 2 USART
  • PIT - 20-bit Programmable Counter plus 12-bit Interval Counter
  • RTT - 32-bit Free-running Counter
  • PIO - 32 Programmable I/O Lines
  • SPI - to 16-bit Programmable Data Length
  • One Three-channel 16-bit Counter
  • 1 Four-channel 16-bit PWM Controller
  • 1 8-channel 10-bit Analog-to-Digital Converter
  • Power Supplies - 3.3V

Demo Video

Downloads

Source code

pro-qwerty.com