AT85C51SND3B Firmware ..............................................................................................
Section 1 Introduction ........................................................................................... 1-1 Section 2 Firmware Features................................................................................ 2-3 2.1 MMI Manager ............................................................................................2-3 2.1.1 Features .............................................................................................2-3 2.1.2 Configuration ................................
Table of Contents 2.12.1 Features .............................................................................................2-8 2.12.2 Configuration ......................................................................................2-8 2.13 Keyboard...................................................................................................2-8 2.13.1 Features .............................................................................................2-8 2.13.2 Configuration ...................
Table of Contents 5.4.2 Generic Modules ..............................................................................5-28 5.4.3 Useful Functions and Macro-functions .............................................5-29 5.4.4 Automatic Screen Refreshing...........................................................5-30 5.4.5 Automatic display .............................................................................5-31 5.4.6 Software Timers .............................................................
Section 1 Introduction The AT85C51SND3Bx is a low power single-chip highly-integrated digital audio decoder/encoder for applications such as audio players, recorders, cell phones, toys… The AT85C51SND3Bx MP3 Player firmware is part of the AT85DVK-07 development kit or the AT 85RF D-0 7 r efer ence des ign dedic ated to the AT 85C5 1SND3B x microcontroller. This document is the User’s Guide of the AT85C51SND3Bx MP3 Player firmware.
Section 2 Firmware Features The following sections describe the AT85C51SND3Bx firmware features and options. Some of the firmware options are not supported by the AT85DVK-07 (e.g. image viewer) or by AT85RFD-07 (e.g. MMC support). 2.1 MMI Manager This module allows customers to easily develop their own MMI applications. 2.1.
Firmware Features 2.2.2 Configuration Connection Speed – authorize high or full speed (depending on the host) – authorize only full speed enable/disable USB Class used (Mass Storage, HID, CDC) USB device information (vendor ID, product ID, manufacturer name, ...) – product name – serial number Class description (Class name, ...) enable/disable Disk Password Management (for Mass Storage Class) 2.3 Host USB This module is the USB host driver. 2.3.
Firmware Features Stream Information – synchronized play time – bit rate – sampling frequency – number of channels Tags – ID3 v1.0, v1.1 – ID3 v2.2 and v2.3 Stereo volume control Sound effects: – bass boost – spatial sound Adjustable 3-band EQ – Classic, Pop, Jazz, Rock… 2.4.2 Configuration DAC Output Selection – internal – external External DAC interface 2.5 Audio Recorder This module allows the end-user to play and record audio streams. 2.5.
Firmware Features 2.7.1 Features Management – load – save – update from a file 2.7.2 Configuration Opened Settings structure content Update file name 2.8 Update This module allows the end-user to perform firmware update of its player. 2.8.
Firmware Features – create – delete – rename Disk management – disk Information – format: FAT12, FAT16, FAT32 2.9.2 Configuration Supported file systems Maximum number of files to manage at same time Cache optimization 2.10 Nand Flash This module is the Nand Flash memory library. 2.10.
Firmware Features 2.11.2 Configuration Enable/disable Bus format: – automatic: depends on card type – 1-bit 2.12 Display This module is the display management library. 2.12.1 Features 2.12.2 Configuration Interface configuration to fit display controller – type: I80/6800 – timings 2.13 Keyboard This module is the keypad driver. 2.13.
Firmware Features 2.15 Clock Manager This module is the system clock driver Oscillator Frequency Clock Type: – crystal – oscillator 2.16 System 2.16.1 Features 2.16.
Section 3 Source Files Organization 3.1 Directory Physical Structure The AT85C51SND3Bx MP3 player firmware source code is composed of several files. This section describes the directory organization of the firmware package. 3.1.1 snd3b-dvk-x_y_z Directory The snd3b-dvk-x_y_z directory contains the firmware package where x_y_z is the firmware version. .................ISP files: codec, picture_, font .............................................user’s system configuration files .........................
Source Files Organization 3.1.3 conf Directory The conf directory contains header files allowing user to configure the Atmel libraries. Its content is detailed in Section 6. ............conf_access.h: configuration of the memory access interfaces .............................................conf_audio.h: configuration of the audio part (HW and SW) .............................................conf_clock.h: configuration of the oscillator frequency .............................................
Source Files Organization 3.1.6 lib_mem Directory The lib_mem directory contains the Atmel high-level memory storage drivers source code. .....................MMC/SD memory card driver .............................................Nand-Flash memory driver 3.1.7 lib_system Directory The lib_system directory contains the Atmel system service source code. ......................automatic display of time-depending graphical objects .............................................
Source Files Organization 3.1.9 modules directory The modules directory contains the Atmel system libraries source code. ...............audio controller library .............................................memory access and data transfer libraries .............................................FAT file system library .............................................MMI manager library .............................................audio player library .............................................
Section 4 Code & Data Management 4.1 Principle The SND3 chip permits: to customise the memory organisation to use a code swap feature (= code banking) to store a large constant data in the NandFlash Reminder: The C51 core use different memory space (code, data, xdata). The size of data space is 256B. The size of code space is limited at 64KB and xdata space is limited at 64KB. 4.1.
Code & Data Management xdata space size, code common size and code bank size* shall be a modulo 512B. Figure 4-1.
Code & Data Management 4.1.1.2 How to configure You must change the configuration in the « option.h » header file by defining following constants: • XDATA_LENGTH • CODE_BANKING • BANK_START_ADDRESS Note: There are no « code size » #define, because this one is automatically computed using XDATA_LENGTH. You must modify the UV2 project according to « option.h » header file; Figure 4-2.
Code & Data Management 4.1.2 Code swap 4.1.2.1 Principle The code load swap consists in the downloading of temporary codes in a part of the microcontroller code section to be executed immediately. When this temporary code has been completely run, the microcontroller automatically runs back on the permanent code or a previous temporary code. This makes it possible to have a code memory space share for temporary codes, expanding then the total code beyond the 64KBytes.
Code & Data Management 4.1.2.3 How to activate code banking? Code banking enable are in the ‘Option for Targets’ pop-up in the Target tab. Figure 4-5. Keil µVision ‘Option for Target’ window – Check the box “Code Banking” and select the maximum number of banks that your application may have to support. For information, the banking frame code size increases with the number of available banks. This number must be reported in the file “lib_system\banking\l51_bank.
Code & Data Management 4.1.2.4 How store a file in a bank ? To store all routines from a C file in a bank , you must set a bank number in file options in KEIL. Figure 4-6. Banking a C file Note: The bank #0 is not to be used, it is reserved for the proper working of the code load swap mechanism. Indeed, it’s the MMI application “mmi_dummy” that takes up this bank although the application does nothing. This configuration must not be modified.
Section 5 Architecture 5.1 Overview The AT85C51SND3Bx firmware is a software platform that provides full and high-level easy to use services. The architecture was carefully designed for both quick chip configuration and easy customizing.
Architecture CUSMTOMER MMI mmi_storage TASK device USB host ATMEL MODULES mmi_player srv_recorder mmi_recorder recorder TASK mmi_viewer viewer TASK Features direct access srv_player TASK player codecs mmi_update mmi_explorer srv_explorer TASK explorer mmi_startup TASK power mmi_status keypad Specifics events KERNEL Nand Flash LCD CODE SWAP System Area con- DEBUG TEXT (mail box) (timer) (MMI manager) (scheduler) Settings Features commands/events access TASK update FILE SY
Architecture 5.3 KERNEL Figure 5-2 presents the execution process of the firmware, this one includes: – a task scheduler to run many tasks simultaneously – a communication based on message to manage the no foreeable commands and events – an MMI manager task to manage an MMI applications stack Figure 5-2.
Architecture 5.3.1 The Scheduler The firmware system is driven by an endless scheduler which activates tasks, one at a time, in a round robin manner. The scheduler loops on a static list. Refer to Section 6.2.12 for configuring the scheduler. Note that each task executes “at will”, i.e. the duration of their execution is not limited. Thus, in order to have the system running smoothly, each task should perform its duty for the shortest amount of time. 5.3.
Architecture “event” is an information dedicated to MMI applications, sent by a task to inform on its status or to give feedback of a previously executed command. These messages are mailed in two separate mailboxes, based on FIFO stacks. The uni-directional communication system is the direct access at the public routines provide by modules. 5.3.3.1 Message Format Command and event messages are composed of 2 words: – a unique ID – an optional 16-bit parameter Command message format Figure 5-4.
Architecture 5.3.3.2 Messages Management The following functions located in file “lib_system\mailbox\mail.c” make it possible the mailing and the delivery of messages. Figure 5-6.
Architecture Figure 5-7. MMI manager principle evt last launched application is placed at the top p r o c e s s i n g highest priority evt evt cmd in out MMI_APPLI_X MMI_APPL_IDLE MMI_APPLI_X MMI_APPLI_STATUS ... MMI_APPLI_IDLE MMI_APPLI_STATUS lowest priority LIFO application stack customer applications mmi manager kernel The MMI application “status” is loaded first in the application stack at the initialization of the MMI manager task.
Architecture 5.4 MMI Applications MMI applications are source code executed under the control of the MMI manager kerel. To achieve this control and to offer flexibility, they organized in modules, are based on a template and are associated to IDs. This one can be use a services MMI which include a usual code sequence to use provided by ATMEL. 5.4.
Architecture – a “switch-case” processes all in-coming events Figure 5-8. internal switch-case processing This minimal structure to respect is to get a proper control of all new MMI applications by the MMI manager kernel. The three basic system events “EVT_START_APPLI”, EVT_APPLI_KILLED”, EVT_BACK_TO_TOP” and others are defined in “lib_system\mailbox\mail_evt.h”. 5.4.
Architecture Table 5-1. Requests from MMI applications to MMI manager kernel Functions or Macro-functions mmgr_activate_mmi_appli( U8 id_appli, U16 param ) Description Name Mailed 3(4)1 EVT_START_APPLI yes Launches an MMI application by pushing it in the application stack with the help of two arguments: - id_appli: the module id defined by the developper in file “mmi\shared\com_appli.h” - param: extra 16-bit parameter. The application is normallyexecuted after a scheduler round.
Architecture – Secondly, from this application up to the top one, their screens are redrawn one after the others. Thus, this mechanism makes it possible to redraw superimposed non-full-screen windows automatically. 5.4.5 Automatic display The automatic display module is charged with managing the display of time-related graphical objects. It enables to make easily animations from pictures placed in a special directory “tools\picture_maker\pictures_demo_default\Animations”.
Architecture The number of available software timers is set to 10 using the macro “NB_TIMER_SOFT”. The tick period is set to 2ms using the macro TICK_PERIOD. These macros are defined in “config.h” and should not be modified. The software timers are dedicated to MMI applications and dynamically attributed by the software timer management. Some functions and macros enables the MMI applications to control these kind of timers. Table 5-4.
Architecture Figure 5-9 gives a graphical representation of the keypad behavior. Figure 5-9. Keyboard timings and events Key Events ➊ ➀ ➋ ➀ ➁ Timings Tags: ➀ KBD_DEBOUNCE_TIMING ➁ KBD_REPEAT_START_TIME ➂ KBD_REPEAT_CONT_TIME ➃ KBD_REPEAT_LONG_TIME ➍ ➌ ➌ ➌ ➌ ➌ ➌ ➌ ➌ ➊ ➀ ➁ ➎ ➂ ➂ ➂ ➂ ➂ ➂ ➂ ➃ ➀ Events Tags: ➊ KBD_KEY_PRESSED ➋ KBD_KEY_RELEASED ➌ KBD_KEY_REPEAT ➍ KBD_KEY_LONGPRESSED ➎ KBD_KEY_REPEAT_RELEASED Figure 5-10.
Architecture 5.5 Services The services are provide by Atmel and include the usual MMI sequences. This one permits to reduce the code in MMI Applications. 5.5.1 Player service The player service provides a MACRO to start MMI_PLAYER with different options. Table 5-7.
Architecture Fonctions Description srvplayer_set_eq() Send to player module the equalizer value srvplayer_eq_modify_predef() Copy the predefine ambiance in the user ambiance definition srvplayer_set_bassboost() Send toplayer module the bassboost state srvplayer_set_vsurround() Send toplayer module the virtual surround state srvplayer_set_speed() Send toplayer module the speed level srvplayer_pause() Pause the play of current file srvplayer_ffw() Start fast foward srvplayer_frw() Start fast
Architecture Fonctions Description srvexp_list_getname_parent() Get the name of directory or disk correponding at file list srvexp_enter() Enter in a disk/directory selected in DISPLAY list Note: A new list is create and DISPLAY list corresponding at the beginning of list srvexp_gotoparent() Go to parent directory/disk Note: A new list is create and DISPLAY list include the previous parent dir srvexp_format() Format the disk selected in DISPLAY list srvexp_delete() Delete a directory/file select
Architecture 5.6 Modules Atmel provides the system modules which permit to use the SND3 chip feature. The modules are USB, player, recorder, viewer, power, explorer and update. The USB modules offers its services to the MMI applications with the help of commands/events or public routines. The following parts decribes the interfaces of each module. 5.6.1 USB Interface The USB module controls the USB device/host mode. Table 5-12.
Architecture Event Label Description EVT_USB_HOST_HID_MOUSE_BTN2 USB host has received an event “clic bouton 2” via a HID device. EVT_USB_HOST_HID_MOUSE_BTN3 USB host has received an event “clic bouton 3” via a HID device. EVT_USB_HOST_HID_MOUSE_MOVE USB host has received an event “mouse move” via a HID device. EVT_USB_HOST_HID_KB_KEY USB has received an event “key press” via a HID device. EVT_USB_HOST_CDC_CHANGE A CDC device has been detected or disconnected.
Architecture Table 5-16.
Architecture Table 5-18. Recorder public routines Routines record_on() Description Initialize the record with: - microphone or line-in as input. - current file selected on current file system navigator. 5.6.
Architecture 5.6.5 Power Interface The Power module controls the power management of the device: – automatically jumps in idle mode to reduce power consumption, – provides battery level information, – provides power-off control, – provides alarm mechanism on a specified low battery level. Table 5-21. Power commands Command Label Description CMD_POWER_OFF Turn the power off (CPU and peripherals stopped). Exit from this hardware state by any key pressed.
Architecture In this document, only the commands and events are described, because a specific document on FileSystem Atmel exists. These services are available through public routines, only the copy/paste features may be use via a commands/event to not break the scheduler. The following commands and events replace the direct access at the routine “nav_file_paste_state()”. Table 5-23.
Architecture 5.7 Debug trace text The TEXT TRACE feature is available only in OCD mode because the text trace is sent to KEIL IDE via OCD dongle. To use it, you must: • uncomment line 14 "#define _TRACE_ (ENABLE)" in debug.c • include following lines in C file to debug #include "config.h" #define _TRACE_ (ENABLE) #include "lib_mcu\debug.h" • use debug routines provide in debug.c, e.g.
Section 6 Firmware Configuration 6.1 Overview Several files have been implemented to help the software developer to quickly configure the firmware. The configuration files “conf_*.h” are all under the conf directory of the firmware package (see Section 3.1.1). There are four kinds of configuration files: Files configuring the Customer MMI layer only The file conf_mmi.h configures exclusively the Customer MMI layer and more precisely the MMI applications organized in modules (see Section 3.1.8).
Firmware Configuration Files configuring the global firmware Two files are under the top-level directory of the firmware package: – config.h: configures the system. Should not be modified. – option.h: configures (de-)activation of peripherals. Also, defines compilation switches.
Firmware Configuration 6.2 Configuration Files This section describes feature by feature the available configuration. In the following tables, the default parameters values are marked in square brackets. 6.2.1 Control Access The “conf_access.h” file is used to configure the access control of all the system memories. The source code of each access interface and logical unit are compiled only if enabled. Table 6-1.
Firmware Configuration Table 6-6.
Firmware Configuration 6.2.3 Clock The “conf_clock.h” file is used to configure the clock that drives the chip. Table 6-8. Clock settings 6.2.4 File System Definition Label Description Values FOSC Oscillator frequency From [12000] up to 26000 (unit in KHz) CLK_DRIVE Oscillator type: - Crystal connected on X1/X2 pins - External oscillator drives X1 input [CLK_CRYSTAL] CLK_GENERATOR The “conf_explorer.h” file is used to configure the file system modules. Table 6-9.
Firmware Configuration Definition Label Description Values EXP_MAX_RANGE_RAND Size of the list to random (option of explorer module) 1 to 100 (unit 8 files) EXP_GET_RAND Process use to get a random value (option of explorer module) use TL0 register 6.2.5 Setting The “conf_explorer.h” file is used to configure the setting modules. Table 6-10.
Firmware Configuration Keypad layout configuration: The keyboard driver can support 5 kinds of matrices up to 12 keys as detailed in the following figures. Table 6-13.
Firmware Configuration – KBD_9_KEYS: a 3x3 matrix keyboard organization C0 C1 C2 R0 KEY_ R0_C0 KEY_ R0_C1 KEY_ R0_C2 VSS R1 KEY_ R1_C0 KEY_ R1_C1 KEY_ R1_C2 P1.3 R2 KEY_ R2_C0 KEY_ R2_C1 KEY_ R2_C2 P1.4 P1.0 P1.1 P1.2 – KBD_6_KEYS: a 3x2 matrix keyboard organization C0 C1 C2 R0 KEY_ R0_C0 KEY_ R0_C1 KEY_ R0_C2 VSS R1 KEY_ R1_C0 KEY_ R1_C1 KEY_ R1_C2 P1.3 P1.0 P1.1 P1.
Firmware Configuration Standard Key definition: standard keys used in MMI applications are mapped here onto the keyboard matrix: Table 6-15. Standard key definition for the AT85DVK07 board version 0.0.1 6.2.
Firmware Configuration Table 6-19. Main features Definition Label Description Values EMBEDDED_CODE_FONT Allow local font usage in code ENABLED [DISABLED] TEXT_SCROLLING Implement or not the code to have the text scrolling available [ENABLED] DISABLED IMAGE_SUPPORT Implement or not the functions to display JPEG pictures ENABLED [DISABLED] LCD interface configurations This section configures the on-chip LCD interface for each LCD module to support. Table 6-20.
Firmware Configuration Table 6-24. Settings 6.2.9 MMI Applications Definition Label Description Values MMC_CARD_SECU_FUNC Secured functions ENABLE [DISABLE] SD_4_BIT 4-bit data bus [ENABLE] DISABLE The “conf_mmi.h” file is used to configured the user’s MMI applications. Table 6-25.
Firmware Configuration Table 6-27. Key mnemonics renaming 6.2.10 Nand-Flash Memory MMI Key Labels Default associated driver key Labels KBD_LOCK_SWITCH KEY_LOCK KBD_MMI_F KEY_MENU KBD_MMI_SELECT KEY_CENTER KBD_MMI_NEXT KEY_RIGHT KBD_MMI_PREV KEY_LEFT KBD_MMI_UP KEY_UP KBD_MMI_DOWN KEY_DOWN KBD_MMI_VOL_HIGH KEY_INC KBD_MMI_VOL_LOW KEY_DEC KBD_MMI_FFW KEY_RIGHT KBD_MMI_FRW KEY_LEFT The”conf_mmc.h” is used to configure the Nand Flash memory driver.
Firmware Configuration Table 6-30. Power type 6.2.12 Scheduler module Definition Label Description Values POWER_SOURCE The power level under which the system has to run: very low (1.8V) or low (3.3V) INTERNAL_VLV_DC_DC EXTERNAL_VLV_REGULATOR [EXTERNAL_LV_DC_DC] EXTERNAL_LV_REGULATOR POWER_EXT_DC_ON External DC-DC control pin [P3_4] I/O pins mnemonics are defined in mcu.h file (See Section 3.1.5).
Firmware Configuration 6.2.13 USB Module Type of scheduler (SCHEDULER_TYPE): only SCHEDULER_FREE is actually supported. The “conf_usb.h” file is used to configure the USB module. There are two level of configuration HIGH (customer) and LOW (expert). This is the HIGH options of configuration : Table 6-31.
Firmware Configuration Table 6-34. Device CDC class configuration Definition Label Description Values USB_DEVICE_CDC_DATA_NAME_INTERFACE Name of CDC data class interface "CDC DATA ATMEL" USB_DEVICE_CDC_COM_NAME_INTERFACE Name of CDC com class interface "CDC COM ATMEL" USB_DEVICE_CDC_COM Implement the CDC com interface for CDC [ENABLED] DISABLED Table 6-35.
Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg.