Home
SPCE SACM Library User`s Manual v3.0
Contents
1. 67 11 5 3 Function Read the speech data from buffer and write to user s storage 68 12 HARDWARE DEPENDENCE API IN SACMVXX ASM OPEN SOURCE eret 71 Ue FUNCTIONS cM 71 12 1 1 Function Ramp up DAC 71 12 1 2 Function Ramp up DAC 71 12 1 3 Function Ramp down DACI ee 72 12 1 4 Function Ramp down DAC2 ou eececceeceeccetscess cee cusecsecaeecaeeesceeseeeaeeeeeeeeeeeeseseseaesnaesnaeesaeens 72 12 2 AD DA FUNCTIONS EE 72 12 2 1 Function Switch SPCE ADC channel for recomling eene 72 12 2 2 Function Get ADC data for recording eese nre 73 12 2 3 Function Send data to DACI iis e e tene ge e gea dE 73 Sunplus Technology Co Ltd PAGE 5 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 12 2 4 Function Send data io DAC2 e est eee etae she ear ese dee e Cc aree oue eode sae rear Een d 73 13 HOW TO ADAPT YOUR OLD PROJECT FOR NEW LIBRARY ee ee ee eee ee eee en nose ense tna 75 13 1 THE SACM PROJECT ARCHITECTURE essen nnnn nnn nnnn nnn nina iniit u aua 75 13 2 STEP BY STEP ee EE 76 14 HOW TO USE THE SPEECH LIBRA RY ee ee ee ee eere eee tono eee tone eee sn sese sone seen see senses enne sese en nee a 77 14 1 THE PROGRAMMING ELO T7 14 2 LINK THE LIBRARIES TO USER S PROGRAM 77 14 3 ADDING RESOURGES EEN N 78 14 4 ASIM
2. 58 NENT XO BILL M 61 11 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACM DVR1600 sse 61 11 1 1 Function Initialize SACM DVR1600 library eese eene e en 61 11 2 SERVICE LOOP FUNCTIONS S SERVICE LOOP FOR SACM DVR1600 DECODING leote 61 11 2 1 Function Foreground service Joen 61 11 2 2 Function Background service Joen 62 11 3 PLAYBACK FUNCTIONS RECORD PLAYBACK CONTROL eite enne ten nene 63 11 3 1 Function Start recording data from MIC to external memory module 63 11 3 2 Function Play DVR1600 speech Pers een 63 11 3 3 Function Stop recording playback eessen 64 11 3 4 Function Pause currently playing SACM DVR1600 speech eene 64 11 3 5 Function Resume paused SACM DVR10600 speech esee enne 65 11 3 6 Function Change the volume of SACM DVR1600 csse eere 65 11 3 7 Function Get the status from SACM DVR1600 module eee 65 11 3 8 Function Change the speed index of SACM DVRIG0OO cessere 66 11 4 ISR FUNCTIONS INTERRUPT SERVICE ROUTINE FOR SACM DVR1600 PLAYBACK RECORDING 66 11 5 USER FUNCTIONS FOR SAGM DVR1600 PLAYBACK IN MANUAL MODE nnns 67 11 5 1 Function Set start address for SACM DVR1600 speech dato 67 11 5 2 Function Read the speech data from user s storage and write to buffer
3. amp sUNPLUS Return Value Library Remark SPCE SACH Library User s Manual v3 0 Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Enable both ramp up and down None Sacm DVR1600 Vxxx LIB Sacm DVR1600 SC Vxxx LIB 1 The data rate of SACM DVR1600 can be compressed by 10 12 14 16 20 24Kbps The data rate is selected by the decoder automatically 2 The Speech Index is the speech sequence of T SACM DVR1600 SpeechTable in resource asm For manual mode playback the Speech Index should be set as 1 And user should implement the USER DVR1600 SetStartAddr and F USER DVR1600 GetData in sacm DVR1600 user asm on users own 3 The F ISR Service SACH DVR1600 can be hooked on the _FIQ IRQ1 or IRQ2 label see isr asm for details before using this function 4 The interrupt service routine ISR is working on 16KHz after calling this subroutine 5 About he details of Ramp Up Down function please refer to section 12 1 Ramp Functions 11 3 3 Function Stop recording playback Syntax C ASM Parameters Return Value Library Remark void SACM_DVR1600_Stop void call F SACM DVHR1600 Stop N A N A Sacm DVR1600 Vxxx LIB lt Sacm_DVR1600_SC_Vxxx LIB gt This function will not change the inter
4. amp sUNPLUS SPCE SACM Library User s Manual v3 0 For SACH V40 03 30 2004 SUNPLUS TECHNOLOGY CO reserves the right to change this documentation without prior notice Information provided by SUNPLUS TECHNOLOGY CO is believed to be accurate and reliable However SUNPLUS TECHNOLOGY CO makes no warranty for any errors which may appear in this document Contact SUNPLUS TECHNOLOGY CO to obtain the latest version of device specifications before placing your order No responsibility is assumed by SUNPLUS TECHNOLOGY CO for any infringement of patent or other rights of third parties which may result from its use In addition SUNPLUS products are not authorized for use as critical components in life support devices systems or aviation devices systems where a malfunction or failure of the product may reasonably be expected to result in significant injury to the user without the express written approval of Sunplus SUNPLUS TECHNOLOGY CO LTD 19 Innovation First Road Science Based Industrial Park Hsin Chu Taiwan R O C 886 3 578 6005 t 886 3 578 4418 a WWW sunplus com tw amp sUNPLUS SPCE SACH Library User s Manual v3 0 0 Table of Content 0 TABLE OF CONTENT 2 1 REVISION HISTORY sss 7 Uu IDOCUMENTIFISTIORY uL EREE 7 12 LIBRARY HISTORY c 7 2 TYPE OF SPEE
5. N A F ISR Service SACM MS01 None None lt Sacm_MS01_ Vxxx LIB gt 1 This function is used invassembly only and it can be hooked on the FIQ IRQ1 or IRQ2 label See isr asm for details 2 The F ISR Service SACM MS01 will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to place user define function in the same FIQ or IRQ EX FIQ push R1 R5 to SP call F ISR Service SACM MO call F User ISR R12C IRQ1 TMA P INT Clear R1 pop R1 R5 from SP reti Sunplus Technology Co Ltd PAGE 57 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 10 5 User Functions for SACM MSO01 playback in manual mode 10 5 1 Function Set start address for SACM MSO01 speech data Syntax C USER_MS01_SetStartAddr ASM call F_USER_MS01_SetStartAddr Parameters User defined Return Value User defined Library sacm_MS01_user asm Remark 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 10 5 2 Function Read the speech data from user s storage and write to buffer Syntax C N A ASM R1 the start address of buffer to write R2 the length of data call F USER _MS01 GetData Parameters Ri the start address of bu
6. Syntax C void SACM S530 Stop void ASM call F SACM S530 Stop Parameters None Return Value None Sunplus Technology Co Ltd PAGE 46 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Library lt Sacm_S530_Vxxx LIB gt Sacm S530 SC Vxxx LIB Remark This function will not change the interrupt setting 9 3 3 Function Pause playing SACM S530 speech Syntax C void SACM S530 Pause void ASM call F SACM S530 Pause Parameters None Return Value None Library lt Sacm_S530_Vxxx LIB gt lt Sacm_S530_SC_Vxxx LIB gt Remark None 9 3 4 Function Resume paused SACM S530 speech Syntax C void SACM S530 Resume void ASM cal EF SACM S530 Resume Parameters None Return Value None Library Sacm S530 Vxxx LIB gt lt Saem_S530_SC_Vxxx LIB gt Remark None 9 3 5 Function Change the volume of SACM S530 Syntax C void SACH S530 Volume int Volume Index ASM R1 Volume Index call F SACM S530 Volume Parameters Volume Index 0 15 0 Min volume 15 Max volume Return Value None Library lt Sacm_S530_Vxxx LIB gt lt Sacm_S530_SC_Vxxx LIB gt Remark None 9 3 6 Function Get the status of the SACM S530 module Syntax Sunplus Technology Co Ltd PAGE 47 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 C unsigned int SACM S530 Status void ASM call F SACM S53
7. define Ramp_Dn 2 define RceMonitorOff 0 define RceMonitorOn 1 int BIT RATE BIT RATE 16K BIT RATE 10K 12K 14K 16K 20K 24K int ADC Channel Mic 0 7 Mic Line In1 Line In6 int Speechlndex 20 int Key main while 1 Key SP_GetCh switch Key case 0x0100 OA8 Vcc Record USER DVR1600 SetStartAddr 4 REC skip 4 Bytes for length header BIT RATE BIT RATE 16K Bit rate 16K bps ADC Channel Mic ADC channel Mic In SACM DVR1600 Rec RceMonitorOff ADC Channel BIT RATE Start recode break case 0x0200 1 OA9 Vcc Stop recording playback SACM DVHR1600 Stop Stop recording playback break case 0x0400 10A10 Vcc Play Manual mode Speech USER DVR1600 SetStartAddr 0 Set start address SACM DVR1600 Play Manual Mode Index DAC1 DAC2 Ramp Up Ramp Dn Manual mode play break default break end of switch Key SACM_DVR1600_ServiceLoop Service loop for SACM playing System ServiceLoop Service loop for Key Scanning end of while 1 end of main b In ism asm Sunplus Technology Co Ltd PAGE 69 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 _FIQ push R1 R5 to SP push registers call F ISR Service SACM DVR1600 ISR R1 C_FIQ_TMA R_INT_Clear R1 clear TimerA FIQ interrupt flag pop R1 R5 from SP pop registers reti return c In sacm_DVR1600_u
8. Add Header exe SACM S530 S485372C exe Add Header exe SACM S200 S200 exe SACM MS01 Midi2Pop exe scfm exe Sunplus Technology Co Ltd PAGE 10 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 3 Auto mode vs Manual mode For SACM playback auto mode and manual mode are distinguished by the ways library fetches data In auto mode playback library fetches the speech data automatically from internal ROM In manual mode playback users have to handle the speech song data fetch byte by byte word by word or block by block Manual mode can work with external devices such as CPU external memory or CPU CPU system configuration topologies For auto mode and manual mode designation the auto mode and manual mode are designated in the play function For example SACM S200 Play 1 DAC1 DAC2 Ramp Up Ramp Dn 1 as speech index is for manual mode and therefore the algorithm initialization would not have to specify the operating mode In new version of SACM library the new manual mode requires the sacm XXXX user asm where XXXX is algorithm name For example sacm A1600 user asm User has to implement the functions of F USER XXXX SetStartAddr F USER XXXX GetData and F USER XXXX WriteData only for DVR1600 in order to execute manual mode These functions are call back functions for library to access memory storage For DVR1600 user can find the call back
9. Ltd PAGE 66 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 place user define function in the same FIQ or IRQ EX FIQ push R1 R5 to SP call F ISR Service SACM DVR1600 call F User ISR R12C IRQ1 TMA P INT Clear R1 pop R1 R5 from SP reti 3 The ISR is working on 16KHz when playback 32KHz when recording 11 5 User Functions for SACM DVR1600 playback in manual mode 11 5 1 Function Set start address for SACM DVR1600 speech data Syntax C ASM Parameters Return Value Library Remark USER DVR1600 SetStartAddr cal F USER DVR1600 SetStartAddr User defined User defined sacm DVR1600 user asm 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g SRAM FLASH 11 5 2 Function Read the speech data from user s storage and write to buffer Syntax C ASM Parameters Return Value N A R1 the start address of buffer to write R2 the length of data call F USER DVR1600 GetData R1 the start address of buffer to write R2 the length of data User defined Sunplus Technology Co Ltd PAGE 67 March 30 2004 amp sUNPLUS Library Remark SPCE SACH Library User s Manual v3 0 sacm_DVR1600_user asm Manual mode use only User implements
10. R2 R1 R_Resouce_BS R2 R1 R1 R1 R1 LSL 4 R1 R1 LSL 4 R1 R1 LSL R Resouce DS R1 pop R1 R2 from sp retf endp Function F USER A1600 GetData Parameter R1 the address to store R2 the to store Return Block data can be a word a byte or an array Description This function called by library to fetch data blocks for playback The Library needs a data block specified n by R1 the start address and R2 the length of the block AAEDIL X o Da HJU G aM Sunplus Technology Co Ltd PAGE 87 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Uaser would have to compose the function body based on the storage type to fulfill this demand from library E F USER A1600 GetData proc user implement this interface to get external data push R1 R4 to SP SR R_A1600_Resouce_DS R3 R_A1600_Resouce_BS L Get Loop cmp R2 0 jz L End R4 D R3 R1 R4 R2 1 cmp R3 0 jnz L_Get_Loop SR 0x0400 R_A1600_Resouce_DS SR jmp L_Get_Loop L_End R_A1600_Resouce_BS R3 pop R1 R4 from SP retf endp Function F USER MS01 GetData Parameter R1 the address to store R2 the to store Retur
11. SPCE SACH Library User s Manual v3 0 7 API for SACM S200 7 1 Hardware Dependent Function Initializes SACM S200 7 1 4 Function Initialize the S200 library Syntax C void SACM S200 Initial void ASM call F SACM S200 Initial Parameters N A Return Value N A Library Sacm S200 SC V e LIB Remark 1 This function initializes the SACM S200 decoder It also initializes the system clock Timer A DAC and enables the Timer A FIQ with 16KHz sample rate 2 The hardware setting is opened for user s reference see F SP SACM S200 Init function in sacmvxxx asm 3 This function utilizes a register H InterruptStatus spce asm to work with user s program for SPCE500A It uses P INT Mask instead for SPCE 061A 060A 7 2 Service Loop Functions Service loop for SACM S200 decoding 7 2 4 Function Foreground service loop Syntax C void SACH S200 ServiceLoop void ASM call F SACM S200 ServiceL oop Parameters None Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark Foreground service loop has to be placed in main loop 7 2 2 Function Background service loop Syntax Q N A Sunplus Technology Co Ltd PAGE 27 March 30 2004 amp sUNPLUS ASM Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 Call F SACM S200 ServiceLoop ISR N A N A Sacm S200 SC_Vxxx LIB gt 1 Background service loop is placed in either FI
12. Syntax C void SACM_MS01_Resume void ASM call F SACH MS01 Resume Parameters None Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark 10 3 5 Function Change the volume of SACM MS01 Syntax C void SACH MS01 Volume int Volume Index ASM R1 Volume Index call F SAGM MSO01 Volume Parameters Volume Index 0 15 0 Min volume 15 Max volume Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark None 10 3 6 Function Get the status of the SACM MS01 module Syntax C unsigned int SACM MS01 Status void ASM call F SACH MSO01 Status Return Value R1 Sunplus Technology Co Ltd PAGE 55 March 30 2004 amp sUNPLUS Parameters None Return Value bit 0 0 Speech ended 1 Speech Playing bit 1415 Reserved Library lt Sacm_MS01_Vxxx LIB gt Remark None MS01 Built in Tone Color List SPCE SACM Library User s Manual v3 0 ZZ SACM MS01 Tone colors Suggested Pitch Range Performance 00 Piano 1 77 1 77 01 Marimba 1 7 178 The higher pitch the higher volume 02 Music Box 7 2 7 2 H 03 Guitar 1 2 4 3 2 04 Cello 1 1 278 1 2 05 Violin 1 77 1 06 French Horn 5 2 5 7 2 ft 07 Flute 1 1 14 1 14 08 E Piano 1 278 The higher pitch the higher volume 09 Harpsichord 1 6 1 6 0A Clav
13. 1 24 1 724 0B Vibraphone 3 Ss Que 0C Bell A T 4 7 OD Nylon str Gt 1 1 1 1 0E Steel str Gt 1 7 1 1 OF Jazz Gt 1 gt V 1 1 10 Clean Gt WN B 1 7 11 Distortion Gt 1 6 1 7 12 Bass 1 7 1 7 13 Banjo 1 1 77 1 77 14 Banjo 2 1 4 1 7 15 Violin 2 2 1 2 1 16 Viola 2 1 2 1 17 Cello 2 1 45 1 71 18 Contrabass 1 21 1 71 19 Trumpet 1 7 1 6 1A Oboe 1 1 43 1 21 1B Oboe 2 1 43 1 2 1C English Horn 1 41 1 7 1D Clarinet 1 7 1 2 1E Piccolo 1 7 178 1 1 1F Flute 2 1 18 1 14 20 Recorder 1 7 18 1 5 21 Whistle 1 2 1 2 22 SFX 1 278 1 2 e Octave 0 e Octave 1 e Octave 2 Sunplus Technology Co Ltd PAGE 56 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 e lt space gt Octave 3 e ii Octave 4 Octave 5 Octave 6 sharp mark OctaveO CO CO DO DO EO FO FO GO GO AO AO BO Octave1 C1 C1 D1 D1 E1 F1 F1 G1 G1 A1 A1 B1 Octave6 C6 C6 D6 D6 E6 F6 F6 G6 G6 A6 A6 B6 10 4 ISR Functions Interrupt service routine for SACM MS01 This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or IRQ1 or IRQ2 depending on Timer used The initial function F SP SACM MS01 Init in sacmvxxx asm must also be updated as well Syntax C ASM Parameters Return Value Library Remark
14. Manual mode play speech SACM MS01 ServiceLoop Service loop for decode end of SACM MS01 Play end of if Mode Manual end of main b In ism asm FIQ push R1 R5 to SP push registers call F ISR Service SACM Mo ISR Sunplus Technology Co Ltd PAGE 59 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 R12C FIQ TMA R INT Clear R1 clear TimerA FIQ interrupt flag pop R1 R5 from SP pop registers reti return c In sacm MS01 user asm manual mode only USER MS01 SetStartAddr defined by user F USER MSO01 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf F USER MS01 GetData defined by user F USER MS01 GetData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf Sunplus Technology Co Ltd PAGE 60 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 11 API of SACM DVR1600 11 1 Hardware Dependent Function Initializes SACM DVR1600 11 1 1 Function Initialize SACM DVR1600 library Syntax Q ASM Parameters Retu
15. None Library sacmvxx asm Remark SPCE SACH Library User s Manual v3 0 1 This hardware dependent function will implement different code segment based on the BODY TYPE setting For detail please refer to spce inc and sacmvxx asm 2 XXXX means algorithm title e g S200 S480 S530 MS01 A1600 DVR1600 Sunplus Technology Co Ltd PAGE 74 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 13 How to adapt your old project for new library 13 1 The SACM project architecture Since SACMV32 the library has some minor changes over its architecture so that the project architecture has a minor adjustment as well main c sacmVnn h sp lib h d f User sacm user asm sacmVnn lib sacmVnn asm sp lib asm Isr asm Spce asm System asm Modules Resource S s Spce Inc Spce inc asm Spce inc Spce inc Annn inc Spce inc Sp lib inc Spce inc Spce Inc Fig A typical SACM project architecture In the SACM examples user shall see an architecture like the demonstration above User will also notice that the hardware asm and key asm if applicable are disappeared In the hardware asm there are 3 types of information
16. before using this function 4 The interrupt service routine ISR is working on 16KHz after calling this subroutine 5 About the details of Ramp Up Down function please refer to section 12 1 Ramp Functions 8 3 2 Function Stop playing SACM S480 S720 speech Syntax C ASM Parameters Return Value Library Remark void SACM S480 Stop void call F SACM S480 Stop None None lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB This function will not change the interrupt setting Sunplus Technology Co Ltd PAGE 38 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 8 3 3 Function Pause playing SACM S480 S720 speech Syntax C void SACM S480 Pause void ASM call F SACM S480 Pause Parameters None Return Value None Library lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB Remark None 8 3 4 Function Resume paused SACM S480 S720 speech Syntax C void SACM_S480_Resume void ASM call F SACH S480 Resume Parameters None Return Value None Library lt Sacm_S480_Vxxx LIB gt lt Sacm_S480_SC_Vxxx LIB gt Remark None Example None 8 3 5 Function Change the volume of SACM S480 S720 Syntax C void SACM S480 Volume int Volume Index ASM R1 Volume Index call F SACH S480 Volume Parameters Volume Index 0 15 0 Min volume 15 Max volume Return Values None Library lt Sacm_S480_Vxxx LIB gt Sacm S480 SC V
17. And user should implement the lt USER A1600 SetStartAddr and F USER A1600 GetData in sacm A1600_user asm on users own 3 The F ISR Service SACH A1600 can be hooked on the _FIQ IRQ1 or IRQ2 label see isr asm for details before using this function 4 The interrupt service routine ISR is working on 16KHz after calling this subroutine 5 About the details of Ramp Up Down function please refer to section 12 1 Ramp Functions 6 3 2 Function Stop playing SACM A1600 speech Syntax C ASM Parameters Return Value Library Remark void SACM_A1600_Stop void call F_SACM_A1600_Stop None None lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt This function will not change the interrupt setting Sunplus Technology Co Ltd PAGE 21 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 6 3 3 Function Pause playing SACM A1600 speech Syntax C void SACM A1600 Pause void ASM call F SACM A1600 Pause Parameters None Return Value None Library lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt Remark None 6 3 4 Function Resume paused SACM A1600 speech Syntax C void SACM_A1600_Resume void ASM call F SACM A1600 Resume Parameters None Return Value None Library lt Sacm_A1600_Vxxx LIB gt Sacm A1600 SG Vxxx LIB Remark None 6 3 5 Function Change the volume of SACM A1600 Syntax C void S
18. C_FIQ_TMA Clear Interrupt flag P_INT_Clear R1 pop R1 R5 from SP reti Resource asm T SACH A1600 SpeechTable DW Speech Addr1 Speech index 0 DW Speech Addr2 Speech index 1 14 5 Quick instructions The easiest way to start your own SACM project is to start from a sample proj ct in SACM library package Then you can simply insert your application code into the sample project Instructions 1 Open the sample project that contains the SACM algorithm you need 2 Modified the Hardware setting in spce inc and sacmvxx asm in necessary e g BODY TYPE C SystemClock C A1600 Timer Setting F SP SACM A1600 Init 3 Rebuild project 4 Add user resources into the project resources rebuild project check ROM allocation and edit Speech Tables e g T SACM A1600 SpeechTable 5 Rebuild project 6 Rewrite main c and rebuild project to test the speech files you just added e g MaxSpeechNum 7 Addapplication code to the project in either C or assembly and modified the main c main asm for flow control 14 6 Interrupt Status Register Programmers may share the interrupt source with SACM library A register R_InterrruptStatus is a public interrupt control register in spce asm for SPCE120A 250A 380A500A This register is reserved for sharing the interrupt source and it records the status of occupied interrupt by library therefore it is an interface to identify which interrupt is used by l
19. F SACM S530 Initial Parameters None Return Value None Library lt Sacm_S530_Vxxx LIB gt Sacm S530 SC Vxxx LIB Remark 1 This function initializes the decoder of SACM S530 It also initializes the system clock Timer A DAC and enables the Timer AFIQ at 16KHz sample rate 2 The hardware setting is opened for user s reference see F SACM S530 Init function in sacmvxxx asm 3 This function utilizes a register H InterruptStatus spce asm to work with user s program if for SPCE500A It uses P_INT Mask instead if for SPCE 061A 060A 9 2 Service Loop Functions Service loop for SACM S530 decoding 9 2 4 Function Foreground service loop Syntax C void SACH S530 ServiceLoop void ASM call F SACM S530 ServiceL oop Parameters None Return Value None Library lt Sacm_S530_Vxxx LIB gt Sacm S530 GC Vxxx LIB Remark Foreground service loop has to be placed in main loop 9 2 2 Function Background service loop Syntax Q N A Sunplus Technology Co Ltd PAGE 44 March 30 2004 amp sUNPLUS ASM Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 Call F SACM S530 ServiceLoop ISR N A N A lt Sacm_S530_Vxxx LIB gt Sacm S530 GC Vxxx LIB 1 Background service loop is placed in either FIQ or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the S530 code
20. ISR Service SACM S530 ISR R1 C_FIQ_TMA R_INT_Clear R1 l clear TimerA FIQ interrupt flag pop R1 R5 from SP pop registers reti return c In sacm S530 user asm manual mode only USER S530 SetStartAddr defined by user F USER S530 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf F USER S530 GetbData defined by user F USER S530 GetData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf AD M H A c M J 1 X Ha G mc Sunplus Technology Co Ltd PAGE 51 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 10 API for SACM MSO01 10 1 Hardware Dependent Function Initializes SACM MS01 10 1 1 Function Initialize SACM MS01 library Syntax C void SACM MS01 Initial void ASM Call F SACM MS01 Initial Parameters None Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark 1 This function initializes the decoder of MS01 It also initializes the system c
21. Manual v3 0 if BODY TYPE SPCE061A R1 P INT Mask endif if BODY TYPE SPCE500A R1 R InterruptStatus endif R1 C FIQ TMA Enable Timer B FIQ R_InterruptStatus R1 P INT Ctrl R1 retf Step 5 In order to play two algorithms simultaneously and correctly the service loop routines of MS01 and A1600 are set according to user s choice in step1 EX FIQ push R1 R5 to SP R1 C_FIQ_TMA test R1 P_INT_ Ctrl jne L_FIQ_TimerA Timer A FIQ entrance R1 C_FIQ_TMB test R1 P_INT Ctrl jne L_FIQ_TimerB Timer B FIQ entrance L_FIQ_TimerA eege e Ge hook Timer AFIQ subroutine here and define it to be external call F ISR Service SACM A1600 A1600 FIQ TMA Service call F ISR Service SACM MS01 MS01 FIQ_TMA Service JL nnn monn niinniin aaan R1 F SACM A1600 ServiceLoop ISR Background Service loop for SACM1600 push R1 to SP push SR to SP R1 C_FIQ_TMA P INT Clear R1 reti Sunplus Technology Co Ltd PAGE 91 March 30 2004 amp sUNPLUS L FIQ TimerB R1 C_FIQ_TMB P_INT_Clear R1 pop R1 R5 from sp reti SPCE SACH Library User s Manual v3 0 Step 6 In the main c initialize the SACM MS01 and SACM A1600 Users can arrange the songs and instruments in T SACM MS01 SpeechTable and T SACM MS01 DrumrTable in resource asm at you own The speech table for A1600 is T SACM A1600 SpeechTable EX main System_
22. Remark None 7 3 7 Function Change the speed index of SACM S200 Syntax C void SACM S200 Speed int Speed Index ASM R1 Speed Index call F SACM S200 Speed Parameters Speed Index 2 2 0 Normal speed 2 Min speed 2 Max speed Return Value None Library Sacm S200 SC V e LIB Remark 1 Min speed Speed Index 2 is 1 2 of Normal speed Speed Index 0 2 Max speed Speed Index 2 istwice of Normal speed Speed Index 0 7 3 8 Function Set constant pitch index of SACM S200 Syntax C void SACM S200 PitchO int PitchO Index ASM R1 PitchO Index calls EF SACM S200 PitchO Parameters PitchO Index 2 2 0 Normal pitch 2 lowest pitch 2 highest pitch Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark None 7 3 9 Function Change the pitch index of SACM S200 Syntax C void SACM S200 Pitch1 int Pitch1 Index Sunplus Technology Co Ltd PAGE 31 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 ASM R1 Pitcht Index call F SACM S200 Pitch1 Parameters Pitch1 Index 2 2 0 Normal pitch 2 lowest pitch 2 highest pitch Return Value None Library Sacm S200 SC V e LIB Remark None 7 3 10 Function Change voiced index of SACM S200 Syntax C void SACM S200 Voice int Voice Index ASM R1 Voice Index cal EF SACM S200 Voice Parameters Voice Index 2 2 0 Normal 2 pure unvoice
23. Sacm S480 SC Vxxx LIB 1 This function is used in assembly only and it can be hooked on the FIQ IRQ1 or IRQ2 label See isr asm for details 2 The F ISR Service SACM S480 will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to place user define function in the same FIQ or IRQ Sunplus Technology Co Ltd PAGE 40 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 EX FIQ push R1 R5 to SP call F ISR Service SACM S480 call F User ISR R12C IRQ1 TMA P INT Clear R1 pop R1 R5 from SP reti 8 5 User Functions for SACM S480 S720 playback in manual mode 8 5 1 Function Set start address for SACM S480 S720 speech data Syntax C USER S480 SetStartAddr ASM call F USER S480 SetStartAddr Parameters User defined Return Value User defined Library sacm S480 user asm Remark 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 8 5 2 Function Read the speech data from user s storage and write to buffer Syntax C N A ASM R1 the start address of buffer to write R2 the length of data call F USER S480 GetData Parameters R1 the start address of buffer to write R2 the length of
24. accessible It will take some efforts to change from old version project to new one User can contact Sunplus representative for technical support through Sunplus web site http www sunplus com tw Sunplus Technology Co Ltd PAGE 76 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 14 How to use the speech library 14 4 The programming flow Set Storage Set Storage Start Address Start Address v v Initial Encoder Initial Decoder ISR gt EE Buffer adi Data JOSLADE Bare From Storage Encoder Y Decoder In Buffer Encoder Out Buffer J Decoder Write Data ISR To Storage Decoder Out Buffer LS Send to DAC Record Playback 14 2 Link the libraries to user s program Project gt Setting gt Link and add library i e sacmv40a lib to the library modules text box 9 5480 files General Option Link Section Redefine Hardware IC Source Files IO CC Head Files H 0 External Depen EI Output Output file name ADebugis480 537 C ISK 537 JV Generate Interrupt Vector Table IV Include Start Up Code Align all resources with n v Generate Initial Table External Symbol Files zx Library modules cmacro lib jLibrary SACM_5480_40a lib we Cancel Note If there is any C program in user s project user
25. call YF_SACM_A1600_ServiceLoop Parameters None Return Value None Library lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt Remark Foreground service loop has to be placed in main loop 6 2 2 Function Background service loop Syntax Q N A Sunplus Technology Co Ltd PAGE 19 March 30 2004 amp sUNPLUS ASM Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 call F SACM A1600 ServiceLoop ISR None None lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt 1 Background service loop is placed in either FIQ or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the A1600 code is allocated in page 0 to assure that program flow can proceed to F_SACM_A1600_ServiceLoop_ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background service loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allowe the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refer to Sunplus u nSP Assem
26. is allocated in page 0 to assure that program flow can proceed to F SACM S530 ServicelLoop ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background service loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allowe the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refer to Sunplus u nSP Assembly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP call F ISR Service SACM 530 Interrupt service routine HIE SACH S530 ServiceLoop ISR Background Service loop for SACM S530 playing push R1 to SP push function address to stack push SR to SP push SR to stack Rt FIQ TMA P INT Clear R1 reti 9 3 Playback Functions Playback control 9 3 1 Syntax C ASM Function Play a SACM S530 speech void SACM S530 Play int Speech Index int Channel int Ramp Set R1 Speech Index Sunplus Technology Co Ltd PAGE 45 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 R2 Channel R3
27. on the top of the file Where xxxx inc can be s200 inc s480 inc s530 inc A1600 inc ms01 inc or DVR1600 inc 2 4 IF R InterruptStatus is used add external H InterruptStatus to the top ofthe file 3 Find each line include hardware h inside C files in project 4 Check the file where the line include hardware h presents 2 1 If SPCE port definition is used in the module then add include spce h on the top of the file 2 2 If any key function is used in the module then add tinclude sp lib h on the top of the file 2 3 If any SACM library function is used in the module then add include sacmvxx h on the top of the file 5 Remove hardware asm hareware inc key asm if applicable key inc if applicable from project and add in source files sacmVxx asm spce asm sp lib asm sacm user asm if applicable and header files spce inc xxxx inc and sacmVxx h to project 6 Open spce inc to check out the Body Type definition on the top of the file Change the definition according to the body used 7 Remove the old library and link the new library in Project gt Setting gt Link 8 Check the project content and see if the library API is still supported in new library structure If not modify the program structure according to the examples foreground background auto mode manual mode and SACM XXXX user asm User will see that the new SACM library structure is more
28. play SACM_A1600_Initial Initialization USER_A1600_SetStartAddr Speechindex Set start address of speech data SACM A1600 Play Manual Mode Index DAC1 DAC2 Ramp_Up Ramp_Dn Sunplus Technology Co Ltd PAGE 25 March 30 2004 amp sUNPLUS SACM A1600 ServiceLoop end of SACM A1600 Play end of if Mode Manual end of main b In ism asm _FIQ push R1 R5 to SP call F ISR Service SACM A1600 R1 C_FIQ_TMA R_INT_Clear R1 pop R1 R5 from SP reti c In sacm_A1600_user asm manual mode only USER A1600 SetStartAddr defined by user SPCE SACH Library User s Manual v3 0 Manual mode play speech Service loop for decode push registers ISR clear TimerAFIQ interrupt flag pop registers return F USER A1600 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf F USER A1600 GetData defined by user F USER A1600 GetData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf Sunplus Technology Co Ltd PAGE 26 March 30 2004 amp sUNPLUS
29. playing push R1 to SP push function address to stack push SR to SP push SR to stack R12C FIQ TMA P INT Clear R1 reti Sunplus Technology Co Ltd PAGE 62 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 11 3 Playback Functions Record Playback control 11 3 1 Function Start recording data from MIC to external memory module Syntax Q ASM Parameters Return Value Library Remark void SACM_DVR1600_Rec int RceMonitor int ADC_Channel int Bit Rate R1 RceMonitor R2 ADC Channel R3 Bit Rate call F SACM DVR Record RceMonitor 0 RceMonitorOff ADC data not sent to DAC 1 RceMonitorOn ADC data sent to DAC ADC Channel 0 Microphone 1 7 Line in for SPCEO40A 060A 061A 0 Microphone 1 Line in for SPCE120A 250A 380A 500A Bit Rate 0 BIT RATE 10K 1 BIT RATE 12K BIT RATE 14K BIT RATE 16K BIT RATE 20K BITRATE 24K a fF C ND N A Sacm DVR1600 Vxxx LIBs lt Sacm_DVR1600_SC_Vxxx LIB gt 1 When SACM DVR1600_Rec is called it will call from inside the F SP SwitchChannel in sacmvxxx asm according to the ADC channel specified 11 3 2 Function Play DVR1600 speech Syntax C ASM Parameters void SACM DVR1600 Play int Speech Index int Channel int Ramp Set R1 Speech Index R2 Channel R3 Ramp Set call F SACM DVHR1600 Play Sunplus Technology Co Ltd PAGE 63 March 30 2004
30. the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g SRAM FLASH This function is call back function for SACM DVR1600 library to read speech data from memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that library wants to get 11 5 3 Function Read the speech data from buffer and write to user s storage Syntax C ASM Parameters Return Value Library Remark Example R1 the start address of buffer to read R2 the length of data F USER DVR1600 WriteData R1 the start address of buffer to read R2 the length of data User defined sacm DVH1600 user asm Manual mode use only User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g SRAM FLASH This function is call back function for SACM A1600 library to write encoded data to memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that library wants to write SACM DVR1600 record and playback a In main c include define define define sacmv40 h Manual Mode Index 1 DAC1 1 DAC2 2 Sunplus Technology Co Ltd PAGE 68 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 define Ramp_Up
31. will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to place user define function in the same FIQ or IRQ EX FIQ push R1 R5 to SP call F ISR Service SACM S530 call F User ISR R1 C_IRQ1_TMA P_INT_Clear R1 pop R1 R5 from SP reti 9 5 User Functions for SACM S530 playback in manual mode 9 5 1 Function Set start address for SACM S530 speech data Syntax C USER S530 SetStartAddr ASM call F USER S530 SetStartAddr Parameters User defined Return Value User defined Library sacm S530 user asm Remark t Manual mode use only 2 Userimplements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 9 5 2 Function Read the speech data from user s storage and write to buffer Syntax C User defined ASM R1 the start address of buffer to write R2 the length of data call F USER S530 GetData Parameters R1 the start address of buffer to write Sunplus Technology Co Ltd PAGE 49 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 R2 the length of data Return Value User defined Library sacm S530 user asm Remark 1 Manual mode use only 2 Userimplements the function based on the storage type The memory interface has to be constr
32. 0 Status Retrun Value R1 Parameters None Return Value bit 0 0 Speech ended 1 Speech Playing bit 1 15 Reserved Library lt Sacm_S530_Vxxx LIB gt Sacm S530 GC Vxxx LIB Remark None 9 3 7 Function Change the speed index of SACM S530 while playing Syntax Q void SACM S530 Speed int Speed Index ASM R1 Speed Index call F SACM S530 Speed Parameters Speed Index 12 12 0 Normal speed 12 Min speed 12 Max speed Return Value None Library lt Sacm_S530_SC_Vxxx LIB gt Remark 1 Min speed Speed Index 12 is 1 2 of Normal speed Speed Index 0 2 Maxspeed Speed Index 12 is twice of Normal speed Speed Index 0 9 4 ISR Functions Interrupt service routine for SACM S530 This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or IRQ1 or IRQ2 depending on Timer used The initial function F SP SACH S530 Init in sacmvxxx asm must also be updated as well Syntax C N A ASM Call F ISR Service SACM 8530 Parameters None Return Value None Library lt Sacm_S530_Vxxx LIB gt lt Sacm_S530_SC_Vxxx LIB gt Remark 1 This function is used in assembly only and it can be hooked on the _FIQ IRQ1 or IRQ2 label See isr asm for details Sunplus Technology Co Ltd PAGE 48 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 2 TheF ISR Service SACM S530
33. 00 10 12 14 16 20 24 Kbps Audio SACM A1600 SC 10 12 14 16 20 24 Kbps Audio with Speed Control Speech Present Algorithm Title Data rate pplication SACM S200 SC 0 8K 0 9K 1K 1 2K 1 4K 1 6K Speech 1 8k 2K 2 4K 2 8K 3 36Kbps SACM S480 S720 4 8 7 2 Kbps Speech SACM S480 S720 SC 4 8 7 2 Kbps Speech with Speed Control SACM S530 5 3K 5 96K 6 63K 7 29K 7 95 Kbps Speech SACM S530 5 3K 5 96K 6 63K 7 29K 7 95 Kbps Speech with Speed Control Melody Present Algorithm Title Data rate a Channel Application SACM MS01 IN A 6 4 FM 2 ADPCM Music Synthesizer Recording Present Algorithm Title Data rate Application SACM DVR1600 10 12 14 16 20 24 Kbps Recording A1600 decoder and encoder SACM DVR1600 SC 10 12414 16 20 24 Kbps Recording with Speed Control A1600 decoder and encoder Speed control only for decoder 2 2 Naming convention SACM Xnnn SC SACM Speech Audio Coding Method X A Audio S Speech MS Melody nnn Data rate for XA or S Synthesizer type for X MS 01 FM 02 Wave table SC Speed Control Sunplus Technology Co Ltd PAGE 8 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 DVR Digital Voice Recording Example SACM A1600 stands for Sunplus audio algorithm with nominal data rate of 16Kbps The actual data rate depends on the options provided and the sampling rate adopted 2 3 Algo
34. 2 bit 15 is reserved Library lt Sacm_DVR1600_Vxxx LIB gt Sacm DVR1600 GC Vxxx LIB Remark For both auto and manual modes 11 3 8 Function Change the speed index of SACM DVR1600 Syntax Q void SACM DVR1600 Speed int Speed Index ASM R1 Speed Index call F SACH DVH1600 Speed Parameters Speed Index 12 12 0 Normal speed 12 Min speed 12 Max speed Return Value None Library lt Sacm_DVR1600_SC_Vxxx LIB gt Remark 1 Min speed Speed Index 12 is 1 2 of Normal speed Speed Index 0 2 Max speed Speed Index 12 is twice of Normal speed Speed Index 0 11 4 ISR Functions nterrupt service routine for SACM DVR1600 playback recording This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or IRQ1 or IRQ2 depending on Timer used The initial function F SP SACH DVH1600 Init in sacmvxxx asm must also be updated as well Syntax C N A ASM Call F ISR Service SACM DVR1600 Parameters None Return Value None Library Sacm DVR1600 Vxxx LIB lt Sacm_DVR1600_SC_Vxxx LIB gt Remark 1 This function is used in assembly only and it can be hooked on the FIQ IRQ1 or IRQ2 label See isr asm for details 2 The F ISR Service SACM DVHR1600 will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to Sunplus Technology Co
35. 2 Function Read the speech data from user s storage and write to buffer 49 10 APT FOR SACMM 52 10 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACM MS01 cececcesceseeeeceeeseseeeeesenseeseeseesseeteneaeas 52 10 1 1 Function Initialize SACM MSO1 bro 52 10 2 SERVICE LOOP FUNCTIONS SERVICE LOOP FOR SACM MSO01 DECODING s sasaseserirerererrtrrereretnrneee enee 52 10 2 1 Function Foreground service Joen 52 10 2 2 Function Background service Joan 52 10 3 PLAYBACK FUNCTIONS PLAYBACK CONTROL eese nennen nnne nennen nennen nennen nnne nnne nnne 53 10 3 1 Function Play a SACM MSO1 melody sess eene 53 10 3 2 Function Stop playing SACM MSO01 meld 54 10 3 3 Function Pause playing SACM MSO1 melody eese 55 10 3 4 Function Resume paused SACM MSO1 meld 55 10 3 5 Function Change the volume of SACM MSO1 csset eene eene 55 Sunplus Technology Co Ltd PAGE 4 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 10 3 6 Function Get the status of the SACM MSO1 mode 55 10 4 ISR FUNCTIONS INTERRUPT SERVICE ROUTINE FOR SACM MS01 sss 57 10 5 USER FUNCTIONS FOR SACM MS01 PLAYBACK IN MANUAL MODE eene enn nennen nnns 58 10 5 1 Function Set start address for SACM MSO01 speech dote 58 10 5 2 Function Read the speech data from user s storage and write to buffer
36. 8 sa main c RES F2 848 EA Resource asm DW offset RES F2 848 ea seg RES F2 848 ea i S480 rc sacm S480 user asm sacmV40 asm End Table SP lib asm Ifesduni m SSC SACM 8480 Speech Table oe User nees to add in the song speech Head Files d External Dependencies for playback based on the RES Table above public T SACH 9480 SpeechTable T SACM 8490 SpeechTable dw RES F2 848 SA dw RES M6 848 SA dw RES F2 872 8A dw RES M6 872 SA 4 i ResourceView S FileView gt fe main c faq Resource asm E EI gt Build Debug X Find In Files 1 Find In Files 2 Ready Ln 54 Col 33 NUM Edit the Speech table e g T SACH S480 SpeechTable for SACM S480 Note The RES F2 S48 SA means the S tart A ddress of RES ource file F2 S48 14 4 A Main C Main simple example SACM_A1600 Initial Initialization for playing SACM_A1600 Play Speech Index DAC1 DAC2 Ramp UpDn On While 1 SACM A16000 ServiceLoop Return 0 Note The Speech Index is the sequence in speech table i e T SACH A1600 SpeechTable in resource asm ISR ASM FIQ push Sunplus Technology Co Ltd PAGE 79 March 30 2004 R1 R5 to SP amp sUNPLUS SPCE SACM Library User s Manual v3 0 call F FIQ Service SACM A1600 Interrupt Service R1
37. ACM_A1600_Volume int Volume Index ASM R1 Volume Index call F SAGCM A1600 Volume Parameters Volume Index 0 15 0 Min volume 15 Max volume Return Value None Library lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt Remark None 6 3 6 Function Get the status of the SACM A1600 module Syntax C unsigned int SACM A1600 Status voidg ASM call F SACM A1600 Status Retrun Value R1 Sunplus Technology Co Ltd PAGE 22 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Parameters None Return Value bit 0 0 Speech ended 1 Speech Playing bit 1 15 Reserved Library lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt Remark None 6 3 7 Function Change the speed index of SACM A1600 Syntax C void SACM A1600 Speed int Speed Index ASM R1 Speed Index call F SACM A1600 Speed Parameters Speed Index 12 12 0 Normal speed 12 Min speed 12 Max speed Return Value None Library Sacm A1600 SC V o LIB Remark 1 Min speed Speed Index 12 is 1 2 of Normal speed Speed Index 0 2 Max speed Speed Index 12 is twice of Normal speed Speed Index 0 6 4 ISR Functions Interrupt service routine for SACM A1600 This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or IRQ1 or JIRQ2 depending on Timer used The initial function F SP SACH A1600 Ini
38. AGE 82 March 30 2004 amp sUNPLUS b e timer setting in P TimerA Data Below is an example of initial A1600 EX F SP SACM A1600 Init R1 C SystemClock IP SystemClock R1 R1 0x0030 P TimerA Ctrl R1 R1 C A1600 Timer Setting IP TimerA Data R1 R1 0x0002 P_ADC_Ctrl R1 R1 0x00A0 P DAC Ctrl R1 R1 Oxffff P INT Clear R4 if BODY TYPE SPCE061A R1 P INT Mask endif if BODY TYPE SPCE500A R1 2 R InterruptStatus endif R1 C FIQ TMA R_InterruptStatus R1 P INT Ctrl R1 retf SPCE SACH Library User s Manual v3 0 Because A1600 service loop is on FIQ timer A select the clock source of timer A in P TimerA Ctrl and Turn off ADC and Mic by setting P ADC Ctrl if not use Assign DAC channels to your speech and melody For example if user wants to play A1600 on DAC1 and melody on DAC2 user shall write 0x00A0 to P DAC Ctrl Enable timer A FIQ for A1600 service loop CPU Clock setting TimerA CKA Fosc 2 CKBz1 Tout off TimerA setting Disable ADC disable MIC In Latch DAC1 by Timer A Latch DAC2 by Timer A Clear interrupt occupied events Enable Timer B FIQ Step 3 Check the F SP SACM MS01 Init for system clock and timer A setting F SP SACM MO Init Sunplus Technology Co Ltd PAGE 83 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manua
39. By Remark V40a 03 30 2004 Ray Cheng SACM library is separated to several individual libraries Include A1600 A1600 DC 8480 8720 8480 SC S720 SC S530 530 SC S200 SC MS01 DVR1600 DVR1600 SC Where SC 2 speed control V32f 05 16 2003 Arthur Shieh Modified FIR MOV style Rison Lo Add C ISR API V32e 04 16 2003 Arthur Shieh Add MS014 S200 S240 S480 S530 Rison Lo Modify SACM library for concurrent V32 12 26 2002 Arthur Ghieh Add A1600 A3200 S200 S530 Adamcar Tseng amp New Auto manual mode Andy Hsu New background service loop New MS01 features Play note Event V1 0 05 27 2001 Andy Set OSRM section for 4 algorithms V0 9B 05 20 2001 Andy Add Ramp Up Dn control for speech playing V0 9A 04 12 2001 Andy Add Manual Mode for SACM A2000 V0 8A 05 08 2001 Andy Add Queue Interface for DVR Record Playback V0 3A 01 11 2001 Andy SACM DVR new functions V0 2B 12 14 2000 Andy New version for A2000 8480 720 S240 MS01 DVR With PC Play function V0 2A 12 14 2000 Andy New version for A2000 8480 720 S240 MS01 DVR No PC Play function VO 1 11 15 2000 Andy Fix a2000 ending bug add speech status function V0 0 09 20 2000 Andy First release Sunplus Technology Co Ltd PAGE 7 March 30 2004 amp suNPLUS SPCE SACH Library User s Manual v3 0 2 Type of Speech Compression Algorithm 2 1 Summary Audio Present Algorithm Title PER SACM A16
40. CH COMPRESSION ALGORITHM cscscsssssssssssscssssscsssssssssssesssssssessesesssegsibesednsees 8 23 SUMMARY ET gis ce Nee 8 2 2 NAMING CONVENTION EG Wi Em EE 8 2 3 ALGORITHM SUPPORTED BY SPCE e A 9s 9 2 4 DIFFERENCE BETWEEN SACM V40 AND SACM V32 e 9 3 AUTO MODE VS MANUAL MODE sees en etd ens tta sensn stato seta ene ie oot ap sensu sees suse ta sensa sens tasses suse ta snae 11 4 SERVICE ERAN D 12 5 MEMORY ALLOCATION PR 17 6 APT FOR SACM A1600 E 19 6 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACM A1600 ssssssseeeen een 19 6 1 1 Functions Initialize the A1600 bro 19 6 2 SERVICE KOOP FUNCTIONS SERVICE LOOP FOR SACM A1600 DECODING eee 19 6 2 1 j Function Foreground service Jop 19 6 2 2 Function Background service Joen 19 6 3 PLAYBACK FUNCTIONS PLAYBACK CONTROL nennen nennen nnne nnn Ea Eaa EERE 20 6 3 1 Function Play a SACM A1600 speech eese ennemi 20 6 3 2 Function Stop playing SACM A1600 speech 21 6 3 3 Function Pause playing SACM A1600 speech essent 22 6 3 4 Function Resume paused SACM A1600 speech 22 6 3 5 Function Change the volume of SACH A Tel 22 6 3 6 Function Get the status of the SACM A1600 mode 22 6 3 7 Function Change the speed index of SACM A1600 sse 23 6 4 ISR FUNCTIONS INTERRUPT SERVICE ROUTINE FOR SACM A1600 ssssssseee e 23 6 5 USE
41. Co Ltd PAGE 42 March 30 2004 amp sUNPLUS SACM S480 ServiceLoop end of SACM S480 Play end of if Mode Manual end of main b In ism asm _FIQ push R1 R5 to SP call F ISR Service SACM S480 R1 2C FIQ TMA R INT Clear R1 pop R1 R5 from SP reti c In sacm S480 user asm manual mode only USER S480 SetStartAddr defined by user SPCE SACH Library User s Manual v3 0 Manual mode play speech Service loop for decode push registers ISR clear TimerAFIQ interrupt flag pop registers return F USER S480 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf F USER S480 GetData defined by user F USER S480 GetData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf Sunplus Technology Co Ltd PAGE 43 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 9 API for SACM S530 9 1 Hardware Dependent Function Initializes SACM S530 9 1 1 Function Initialize SACM S530 library Syntax C void SACM S530 Initial void ASM call
42. EET gt Build Debug X Find In Files 1 Find In Files 2 TAS IDE SPCEDSUA DO1A mainc 218 x pe Edit view Project Build Tools Window Help EE asagar o mime sao sestatadd 8 w st pen BARE Pee sesegmE BE Ed Eil DEE SACH S480 algorithm with play stop pause resume volume up volume down function By Sam Sung Modified by Ray Cheng Platform SPCE061A un3P IDE 1 12 0 Windows 2000 Last modified date d 2003 10 22 First version fe LT ais E EH S480 Resources RES F2 948 RES F2 S72 dd i WEHEO Qwie s e amp tet foo fa Li Ei W Sean fess A IBRAT Resource Files x Lord T Eti SABER f Rescurceview E 4 EI ie gt Build Debug A Find In Files 1 X Find In Files 2 Adding resources Sunplus Technology Co Ltd PAGE 78 March 30 2004 o SUNPLUS SPCE SACH Library User s Manual v3 0 0614 source asm 81 xj n Edit view Project Buld Tools window Help la x ce E QE S Blo cs rn pa er G Frs200_setstatadd amp e wle a Eaa t gi EE f P PO H ih m de en IE En E BE DW offset RES M6 S48 ea seg RES M6 848 ea al EME S480 files GG Source Files RE8 F2 848 SA Isr asm DW offset RES F2 848 sa seg RES F2 34
43. ISR Background Service loop for SACM S480 playing push R1 to SP push function address to stack push SR to SP push SR to stack Rt _FIQ_TMA P INT Clear R1 reti 8 3 Playback Functions Playback control 8 3 1 Syntax C ASM Function Play a SACM S480 S720 speech void SACM S480 Play int Speech Index int Channel int Ramp Set R1 Speech Index Sunplus Technology Co Ltd PAGE 37 March 30 2004 amp sUNPLUS Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 R2 Channel R3 Ramp Set call F SACM S480 Play Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Enable both ramp up and down None lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB 1 The data rate of SACM S480 can be compressed by 4 8 7 2Kbps The data rate is selected by decoder automatically 2 The Speech Index is the speech sequence of T SACM S480 SpeechTable in resource asm For manual mode playback he Speech Index should be set as 1 And user should implement the USER S480 SetStartAddr and F USER S480 GetData in sacm_S480_ user asm on sers own 3 The F ISR Service SACM S480 can be hooked on the _FIQ IRQ1 or IRQ2 label see isr asm for details
44. In newer version of SACM library V40 or later each speech algorithm bas a unique section name which guarantees the simultaneity of speech and music synthesizer If user chooses more than one algorithm in the same project but the program is not going to run more than one algorithm at the same time the advantage of QRAM section is to allow user to share the same physical memory block among different algorithms User can use u nSP IDE Project Setting redefine to align the ORAM address If user is not satisfied with the manual allocation and wants to return to default compiler arrangement users only have to delete the file project name lik in project folder and rebuild all projects The memory allocation will be realigned based on default compiler rules Sunplus Technology Co Ltd PAGE 17 March 30 2004 amp SUNPLUS SPCE SACH Library User s Manual v3 0 The RAM block section definitions as follows Table Name and size of Overlap RAM in the library Overlap RAM definition Overlap RAM Label OVERLAP DVR1600 RAM BLOCK OVERLAP A1600 API BLOCK OVERLAP DVR1600 DM BLOCK A1600 SC OVERLAP DVR1600 RAM BLOCK 781 0x30D OVERLAP A1600 API BLOCK 2 0x2 OVERLAP DVR1600 DM BLOCK OVERLAP DVR1600 SPEED RAM BLOCK OVERLAP DVR1600 RAM BLOCK OVERLAP DVR1600 API BLOCK OVERLAP DVR1600 DM BLOCK OVERLAP DVR1600 RAM BLOCK OVERLAP DVR1600 API BLOCK OVERLAP DVR1600 DM BLOCK 136 0x88 OVERLAP DVR1600
45. Initial SACM A1600 Initial SACH MSp Initial USER A1600 SetStartAddr SpeechIndex SACM A1600 Play 0 DAC1 Ramp Up Ramp Dn USER MSO01 SetStartAddr SonglIndex SACM MS01 Play 0 DAC2 Ramp Up Ramp Dn while 1 SACM_MS01_ServiceLoop Step 7 Add user application code and it is done Initial A1600 Initial MS01 Set start address of A1600 speech data H Play speech on DAC2 Set start address of MS01 music data Play melody on DAC1 Service loop for MS01 Sunplus Technology Co Ltd PAGE 92 March 30 2004 amp suNPLUS SPCE SACH Library User s Manual v3 0 16 Resources List of SACM algorithm 16 1 TABLE 1 RAM Size Unit Decimal Word IRAM ISRAM ORAM OSRAM Ad seosc J NS mo mme SX ome Note DVR1600 includes both A1600 Encoder and A1600 Decoder algorithm 16 2 TABLE 2 ROM Size Unit Decimal Word S530 ero MSO01 DVR1600 A1600 SC S530 SC 480 SC S720 SC S200 SC DVR1600 SC Interrupt Timer Setting 16 KHz Play 32 KHz Rec ADC DAG Sunplus Technology Co Ltd PAGE 93 March 30 2004 amp suNPLUS S530 SC S480 SC S720 SC S200 SC Interrupt A1600 SC TMA FIQ TMA FIQ TMA FIQ SPCE SACH Library User s Manual v3 0 Timer Setting 16 KHz 16 KHz 16 KHz 16 KHz 24 KHz sso sc AC DVR1600 SC TMA FIQ 16 KHz Play 32 KHz Rec ADC DAC 16 4 TABLE 4 CPU Usage Ra
46. Mode Auto SAGM S200_Initial Play mode setting Auto mode play Initialization SACM S200 Play Speechlndex DAC1 DAC2 Ramp_Up Ramp_Dn Play 1 speech While 1 SACM S200 ServiceLoop end of While 1 end of if Mode Auto if Mode Manual SACM S200 Initial USER S200 SetStartAddr Speechlndex Service loop for decode Manual mode play Initialization Set start address of speech data Sunplus Technology Co Ltd PAGE 34 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 SACM S200 Play Manual Mode Index DAC1 DAC2 Ramp Up Ramp Dn Manual mode play speech SACM S200 ServiceLoop Service loop for decode end of SACM S200 Play end of if Mode Manual end of main b In ism asm _FIQ push R1 R5 to SP push registers call F ISR Service SACM S200 ISR R1 C_FIQ_TMA R_INT_Clear R1 clear TimerA FIQ interruptflag pop R1 R5 from SP pop registers reti H return c In sacm S200 user asm manual mode only USER S200 SetStartAddr defined by user F USER S200 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FEASH retf F USER S200 GetData defined by user F USER S200 GetData ar
47. PCE inc the BODY TYPE definition determines the SPCE body type and as a result program can know whether H InterruptStatus or P INT Mask should be refered in sacmvxx asm AD C 2 J M J J Z n c UU Sunplus Technology Co Ltd PAGE 81 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 15 How to setup concurrent algorithms in your application For users who would like to design an application with 2 algorithms up and running there are 2 issues to consider real time and resources Resource issue is quite straight forward and it is about if IC can afford 2 algorithm running at the same time in terms of CPU performance RAM ROM and interrupts The resource information of each individual algorithm can be referred in the appendix of this document For RAM allocation there is a technique ORAM section which is also covered in this document and can be applied at users convenience Currently only SPCE060A 061A 040A can support concurrent algorithm applications For interrupt issue since each of the SACMralgorithms requires one or more interrupts to deliver audio output to DAC the concurrent algorithms will either takes up 2 interrupts or share the same interrupts at the same interrupt frequency User is free to choose either user 1 timer or 2 time
48. PLE EXAMPLE eere WEEN enee eee 79 14 5 QUICK TEE TA WA TE 80 14 6 INTERRUPT STATUS Rosen 80 15 HOW TO SETUP CONCURRENT ALGORITHMS IN YOUR APPLICATION e ee ee eee 82 16 RESOURCES LIST OF SACM ALGORITHM ee ee eee eerte eee en rk eene eee soe ee to aee seen see ea ee eee enne Seen 93 16 1 TABLE 1 RAM SIZE UNIT DECIMAL WORD E 93 16 2 TABLE 2 ROM SIZE UNIT DECIMAL WORD ciuem nnne nere nnren tenente nene 93 16 3 TABLE 3 HARDWARE RESOURCES VS LIBRARY cidae eseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeneeeneeeneees 93 16 4 TABLE 4 CPU USAGE RATE APPROXIMATE 7 essseeseeseeeeeeeenenneen nennen nennen nenne nnete nne 94 16 5 TABLE 5 TIMING LIMITATION LAPPBOAIMATEI nnne nnnen nenne nne nnne 94 16 6 TABLE 6 NAME OF OVERLAP RAM IN THE LIBRARY eene nnn nnn nnn nnn 95 Sunplus Technology Co Ltd PAGE 6 March 30 2004 amp suNPLUS SPCE SACH Library User s Manual v3 0 1 Revision History 1 1 Document History Revision Date By Remark V3 0 03 30 2004 Ray Cheng Add DVR1600 A1600 encoder and decoder Add speed control function in A1600 S480 S720 S530 S200 and DVR1600 Remove A2000 A3200 S240 V2 0 12 26 2002 Arthur Shieh Add A1600 A3200 S200 S530 Add new features to MS01 V1 0 12 26 2001 Andy Hsu New release Revised by Michael Lin 1 2 Library History Revision Date
49. Q or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the S200 code is allocated in page 0 to assure that program flow can proceed to F SACM S200 ServiceLoop ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background service loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allowes the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refer to Sunplus u nSP Assembly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP call F ISR Service SACM 200 Interrupt service routine R1 F SACM_S200 ServiceLoop ISR Background Service loop for SACMS200 playing push R1 to SP push function address to stack push SR to SP push SR to stack Rt FIQ TMA P INT Clear R1 reti 7 3 Playback Functions Playback control 7 3 1 Syntax C ASM Function Play a SACM S200 speech void SACM S200 Play int Speech Index int Channel int Ramp Set R1 Speech Index
50. R FUNCTIONS FOR SACM A1600 PLAYBACK IN MANUAL MODE nnns 24 6 5 1 Function Set start address for SACM A1600 speech data eee 24 Sunplus Technology Co Ltd PAGE 2 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 6 5 2 Function Read the speech data from user s storage and write to buffer 24 T APT FOR SACME S YL ssar sons 27 7 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACM S200 ssssssseeeenee ens 27 7 1 1 Function Initialize the 200 library eese eene nnne nne ennt 27 7 2 SERVICE LOOP FUNCTIONS SERVICE LOOP FOR SACM S200 DECODING cem 27 7 2 1 Function Foreground service Joen 27 7 2 2 Function Background service loop esee 27 7 3 PLAYBACK FUNCTIONS PLAYBACK CONTROL eese nennen nen enne enn ener enne ne 28 7 3 1 Function Play a SACM S200 speech 28 7 3 2 Function Stop playing SACM S200 speech 29 7 3 3 Function Pause playing SACM S200 speech aseene 30 7 3 4 Function Resume paused SACM S200 speech 30 7 3 5 Function Change the volume of SACH KOU eet 30 7 3 6 Function Get the status of the SACM S200 module 30 7 3 7 Function Change the speed index of SACH A2O00 31 7 3 8 Function Set constant pitch index of SACM S200 essere 31 7 3 9 Function Change the pitch index of SACM S200 cessere 31 7 3 10 F
51. R1600 RAM_BLOCK 319 Ox13F 2 0x2 AJoVeRLAPDVR1600 SPEED RAM BLOCK saoen HAM 4oveRLAP_DVR1600_DM_BLOCK 136 0x 88 DVR1600 SC OVERLAP DVR1600 RAM BLOCK 786 0x312 c oveERLAP pvRt600 AP BLOCK 35 0x23 l oveRLAP bvR1600 DM BLOCK 136 0x88 API 2 S530 OVEREAP DVR1600 API BLOCK 351 0x23 BRENNEN WE A1600 SC OVERLAP DVR1600 RAM BLOCK ERN E o o EIERE s530 om BLOCK soen loveRae sso api Brock LL 209 loveRae sso om BLOCK eB OES jovERLAP s530 sPEED RAM BLOCK s2o xen Sunplus Technology Co Ltd PAGE 95 March 30 2004 SUNPLUS SPCE SACH Library User s Manual v3 0 loveRae seo api BLOCK 2K loveRlae sas om BLOCK oag loveRae seo ae BLOCK loveRlae se pw BLOCK soora N MS01 OVERLAP_MS01_RAM_BLOCK 318 Ox13E OVERLAP_MS01_DM BLOCK 130 0x82 Where XXXX SC means that algorithm support speed control function loven Ae S480 DM BLOCK 292 0x124 Sunplus Technology Co Ltd PAGE 96 March 30 2004
52. Ramp_Set call F_SACM_S530_Play Parameters Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Enable both ramp up and down Return Value None Library lt Sacm_S530_Vxxx LIB gt Sacm S530 SC Vxox LIB Remark 1 The data rate of SACM S5300 can be compressed by 5 3 Kbps when sampling is 8KHz The data rate is selected by decoder automatically at decoding The data rate can vary along with the sampling rate That is data rate can be 5 3 Kbps 5 96 Kbps 6 63 Kbps 7 29 Kbps and 7 95 Kbps when the sampling rate is 8KHz 9KHz 10KHz 11KHz or 12KHz 2 The Speech Index is the speech sequence of T SACM S530 SpeechTable in resource asm For manual mode playback the Speech Index should be set as 1 And User should implement the USER S530 SetStartAddr and F USER S530 GetData in sacm S530 user asm on users own 3 The F ISR Service SACM S530 can be hooked on the FIQ IRQ1 or IRQ2 label see isr asm for details before using this function 4 The interrupt service routine ISR is working on 16 18 20 22 24 KHz after calling this subroutine Please refer to F SP SACM S530 Init in sacmvxxx asm for detail 5 About the details of Ramp Up Down function please refer to section 12 1 Ramp Functions 9 3 2 Function Stop playing SACM S530 speech
53. SPEED RAM BLOCK 529 0x211 OVERLAP S530 RAM BLOCK 169 0xA9 2 0x2 228 OxE4 613 0x265 2 0x2 228 OxE4 529 0x211 170 OxAA 2 0x2 2 0x2 OVERLAP MS01 RAM BLOCK 318 0x13E OVERLAP MS01 DM BLOCK 130 0x82 XXXX_SC means that algorithm support speed control function A1600 is decoder of DVR1600 So some A1600 overlap RAM labels are the same as DVR1600 Sunplus Technology Co Ltd PAGE 18 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 6 API for SACM A1600 6 1 Hardware Dependent Function Initializes SACM A1600 6 1 1 Function Initialize the A1600 library Syntax C void SACM A1600 Initial void ASM call F SACM A1600 Initial Parameters None Return Value None Library lt Sacm_A1600_Vxxx LIB gt lt Sacm_A1600_SC_Vxxx LIB gt Remark 1 This function initializes the SACM A1600 decoder It also initializes the system clock Timer A DAC and enables the Timer A FIQ with 16KHz sample rate 2 The hardware setting is opened for user s reference see F_SP_SACM_A1600_Init function in sacmvxxx asm 3 This function utilizesva register R_InterruptStatus spce asm to work with user s program if for SPCE500A Ituses P INT Mask instead if for SPCE 061A 060A 6 2 Service Loop Functions Service loop for SACM A1600 decoding 6 2 1 Function Foreground service loop Syntax C void SACM_A1600_ServiceLoop void ASM
54. Sunplus Technology Co Ltd PAGE 28 March 30 2004 amp sUNPLUS Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 R2 Channel R3 Ramp Set call F SACM S200 Play Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Enable both ramp up and down None Sacm S200 SC V o LIB 1 The data rate of SACM S200 can be compressed by 0 8K 3 36K Kbps The data rate is determined at encoding and selected by the decoder automatically at decoding The data rate can be 0 8K 0 9K 1K 1 2K 1 4K 1 6K 418K 2K 2 4K 2 8K or 3 36Kbps 2 The Speech_Index is the speech sequence of T SACM S200 SpeechTable in resource asm For manual mode playback the Speech Index should be set as 1 And user should implement the USER S200 SetStartAddr and F USER S200 GetData in sacm 200 user asm on users own 3 Ihe FF ISR Service SACM S200 can be hooked on the FIQ _IRQ1 or IRQ2 label see isr asm for details before using this function 4 Theinterrupt service routine ISR is working on 16KHz after calling this subroutine 5 Aboutthe details of Ramp Up Down function please refer to section 12 1 Ramp Functions 7 3 2 Function Stop playing SACM S200 speech Syntax C ASM Parameters Return Valu
55. T Clear R1 reti L FIQ TimerB R1 C_FIQ_TMB P_INT_Clear R1 pop R1 R5 from sp reti Step 5 In the main c initialize the SACM MSO1 and SACM A1600 Users can arrange the songs and instruments in T SACM MS01 SpeechTable and T SACH MS01 DrumTable in resource asm at you own The speech table for A1600 is T SACM A1600_SpeechTable EX main System_Initial SACM_A1600_Initial Initial A1600 SACM MSO 1 Initial Initial MSO1 SACM A1600 Play 0 DAC1 Ramp Up Ramp Dn Play speech on DAC2 SACM MS01 Play 0 DAC2 Ramp Up Ramp Dn Play melody on DAC1 while 1 SACM_MS01_ServiceLoop Service loop for MS01 Sunplus Technology Co Ltd PAGE 85 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Step 6 Add user application code and it is done Manual Mode MS01 A1600 In manual mode users can read speech data from internal ROM or external memory User implements USER XXXX SetStartAddr and F USER XXXX GetData based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH Step 1 Decide what FIQ or IRQ service routine your service loop want to hooks on It is suggested that hooks your ms01 service loop and A1600 service loop on FIQ Timer A at the same interrupt frequency Step2 Modify USER A1600 SetStartAddr F USER A1600 GetData USER MS01 SetStartAddr
56. TERRUPT SERVICE ROUTINE FOR SACH GARE 7720 40 8 5 USER FUNCTIONS FOR SACM S480 S720 PLAYBACK IN MANUAL MODE nns 41 8 5 1 Function Set start address for SACM S480 S720 speech dato 41 8 5 2 Function Read the speech data from user s storage and write to buffer 41 9 APT FOR SACME S530 44 9 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACH GEO 44 9 1 1 Function Initialize SACM S530 library Eeer 44 9 2 SERVICE LOOP FUNCTIONS SERVICE LOOP FOR SACM S530 DECODING EE 44 9 2 1 Function Foreground service Joen NEE 44 9 2 2 Function Background service loop EEN 44 9 3 PLAYBACK FUNCTIONS PLAYBACK CONTROL eese fetten enne ther enden nennen nnne 45 9 3 1 Function Play a SACM S530 speech Ee 45 9 3 2 Function Stop playing SACM S530 speech ee 46 9 3 3 Function Pause playing SACM S530 speech 47 9 3 4 Function Resume paused SACM S530 speech 47 9 3 5 Function Change the volume of SACM 8530 cessent eren eene 47 9 3 6 Function Get the status of the SACM S530 mode 47 9 3 7 Function Change the speed index of SACM S530 while playing sess 46 9 4 ISR FUNCTIONS INTERRUPT SERVICE ROUTINE FOR SACM S530 sssssssssseen 48 9 5 USER FUNCTIONS FOR SACM S530 PEAYBACK IN MANUAL MODE s s s srsrsrsiststtttitittttttttttrtrtntnenemene eme 49 9 5 1 Function Set start address for SACM S530 speech dote 49 9 5
57. and F USER MS01 GetData User implements these functions based on the external storage type For example the speech data are stored in internal ROM area Procedure USER A1600 SetStartAddr Syntax USER A1600 SetStartAddr int Parameter R1 Playlndex Return NONE Description This API allows users to set the beginning address to fetch data This address can be either a ROM address or a external storage address User would have to modify the function body based op the application s need USER A1600 SetStartAddr proc F USER A1600 SetStartAddr push R1 R2 to sp R1 T SACM A1600 SpeechTable R1 R1 R2 R1 ID A1600 Resouce BS R2 R1 R1 R1 R1 LSL 4 R1 R1 LSL 4 R1 R1LSL2 ID A1600 Resouce DS R1 pop R1 R2 from sp Sunplus Technology Co Ltd PAGE 86 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 retf endp Procedure USER MS01 SetStartAddr Syntax USER_MS01_SetStartAddr int Parameter R1 Playlndex Return NONE Description This API allows users to set the beginning address to fetch data This address can be either a ROM address or a external storage address User would have to modify the function body based on the application s need eessen USER MS01 SetStartAddr proc F USER MS01 SetStartAddr push R1 R2 to sp R1 T SACH MS01 SpeechTable R1 R1
58. ble both ramp up and down Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark 1 The SACM MS01 provides six channels melody 0 1 ch are drum channels 2 3 4 5 are FM synthesizer channels 2 The Speech Index is the speech sequence of T SACM MSO01 SpeechTable in resource asm For manual mode playback the Speech Index should be set as 1 And user should implement the USER MSO1 SetStartAddr and F USER MSO01 GetData in sacm MSO01 user asm on users own 3 The F SR Service SACM MS01 can be hooked on the _FIQ _IRQ1 or IRQ2 label see isr asm for details before using this function 4 The interrupt service routine ISR is working on 16KHz after calling this subroutine 5 About the details of Ramp Up Down function please refer to section 12 1 Ramp Functions 10 3 2 Function Stop playing SACM MS01 melody Syntax C void SACM MSO01 Stop void ASM call F SACM MSO01 Stop Parameters None Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark This function will not change the interrupt setting Sunplus Technology Co Ltd PAGE 54 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 10 3 3 Function Pause playing SACM MS01 melody Syntax C void SACM MS01 Pause void ASM call F SACM MSO01 Pause Parameters None Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark None 10 3 4 Function Resume paused SACM MS01 melody
59. bly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP call F ISR Service SACM 41600 Interrupt service routine HIE SACH A1600 ServiceLoop ISR Background Service loop for SACM A1600 playing push R1 to SP push function address to stack push SR to SP push SR to stack Rt FIQ TMA P INT Clear R1 reti 6 3 Playback Functions Playback control 6 3 1 Syntax C ASM Function Play a SACM A1600 speech void SACM A1600 Play int Speech Index int Channel int Ramp Set R1 Speech Index Sunplus Technology Co Ltd PAGE 20 March 30 2004 amp sUNPLUS Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 R2 Channel R3 Ramp Set call F SACM A1600 Play Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Enable both ramp up and ramp down None lt Sacm_A1600_Vxxx LIB gt Sacm A1600 lt SC Vxxx LIB gt 1 The data rate of SACM A1600 can be compressed by 10 12 14 16 20 24Kbps The data rate is selected by decoder automatically 2 The Speech Index is the speech seouence of T SACM A1600 SpeechTable in resource asm For manual mode playback the Speech Index should be set as 1
60. chChannel int ADC Channel ASM R1 ADC Channel Call F SP SwitchChannel Sunplus Technology Co Ltd PAGE 72 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Parameters ADC Channel 0 Microphone 1 7 for Line in for SPCE040A 060A 061A 0 Microphone 1 for Line in for SPCE120A 250A 380A 500A Return Value None Library sacmvxx asm Remark None 12 2 2 Function Get ADC data for recording Syntax ASM Call F SACM DVR1600 GetADC Parameters None Return Value ADC data from SPCE hardware Library sacmvxx asm Remark This hardware dependent function will implement different code segment based on the BODY TYPE setting For details please refer to spce inc and sacmvxx asm 12 2 3 Function Send data to DAC1 Syntax ASM R4 16 bit unsigned PCM data Call FSSACM_XXXX_SendDAC1 Parameters R4 16 bit unsigned PCM data Return Value None Library sacmvxx asm Remark 1 This hardware dependent function will implement different code segment based on the BODY TYPE setting For detail please refer to spce inc and sacmvxx asm 2 XXXX means algorithm title e g S200 S480 S530 MS01 A1600 DVR1600 12 2 4 Function Send data to DAC2 Syntax ASM R4 16 bit unsigned PCM data Call F SACM XXXX SendDAC2 Parameters R4 16 bit unsigned PCM data Sunplus Technology Co Ltd PAGE 73 March 30 2004 amp sUNPLUS Return Value
61. d 2 pure voiced Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark None 7 4 SRFunctions Interrupt service routine for SACM S200 This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or JRQ1 or JIRQ2 depending on Timer used The initial function F SP SACM S200 Init in sacmvxxx asm must also be updated as well Syntax C N A ASM call F ISR Service SACM S200 Parameters None Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark 1 This function is used in assembly only and it can be hooked on the _FIQ IRQ1 or IRQ2 label See isr asm for details 2 TheF ISR Service SACM S200 will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to place Sunplus Technology Co Ltd PAGE 32 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 user define function in the same FIQ or IRQ EX FIQ push R1 R5 to SP call F ISR Service SACM S200 call F User ISR R12C IRQ1 TMA P INT Clear R1 pop R1 R5 from SP reti 7 5 User Functions for SACM S200 playback in manual mode 7 5 4 Function Set start address for SACM S200 speech data Syntax C USER S200 SetStartAdar ASM cal F USER S200 SetStartAddr Parameters User defined Return Value User de
62. data Return Value User defined Library sacm S480 user asm Remark Sunplus Technology Co Ltd PAGE 41 March 30 2004 S Example SUNPLUS SPCE SACM Library User s Manual v3 0 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 3 This function is call back function for SACM S480 library to read speech data from memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that library wants to get Play a SACM S480 speech with Auto mode or Manual mode a In main c include sacmv40 h define Manual_Mode_Index 1 define Manual 0 define Auto 1 define DAC1 1 define DAC2 2 define Ramp_Up 1 define Ramp_Dn 2 int Mode int Speechindex 0 main Mode Auto Play mode setting if Mode Auto Auto mode play SACM_S480_Initial Initialization SACM S480 Play Speechlndex DAC1 DAC2 Ramp_Up Ramp_Dn A Play 1 speech While 1 SACM_S480_ServiceLoop Service loop for decode end of While 1 end of if Mode Auto if Mode Manual Manual mode play SACM_S480_Initial Initialization USER_S480_SetStartAddr SpeechIndex Set start address of speech data SACM_S480_Play Manual_Mode_Index DAC1 DAC2 Ramp_Up Ramp_Dn Sunplus Technology
63. data from memory Manual mode Service Loop C Sene Eee e ASKS noi Foreground Je executed Service Loop Interrupt Service Koutime Foreground Service gt tasks not Service Loop SEN Foreground Service tasks not C 9 executed Service Loop Interrupt Service Routine Foreground Service Ed tasks processed Timing diagram Manual mode Foreground service loop main c sacmVnn lib sacm asm Sacm XXXX user asm Hardware Initialization Initialization Interrupt Service Routine La a Servi e Loop If Backgrpund Service CTS tasks not executed Play DOO Service tasks processed Service tasks not executed Service tasks processed Servi Servi e Loop If Background e Loop If Background Inte Inte Inte SPCE SACM Library User s Manual v3 0 isr asm isr asm rupt Service Routine Ferber Servig e Loop If Backgrpund Tupt Service Routine tupt Service Routine Timing diagram Auto mode Background service loop Sunplus Technology Co Ltd PAGE 15 March 30 2004 amp SUNPLUS SPCE SACH Library User s Manual v3 0 main c sacmVnn lib sacm asm sacm XXXX user asm isr asm Hardware Initialization Initialization Interrupt Service Routine Service Loop Background Service tasks not executed Interrupt Service Routine Service Loop Background Service task
64. e Library Remark void SACM S200 Stop void call F SACM S200 Stop None None Sacm S200 SC V o LIB This function will not change the interrupt setting Sunplus Technology Co Ltd PAGE 29 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 7 3 8 Function Pause playing SACM S200 speech Syntax C void SACM S200 Pause void ASM call F SACM S200 Pause Parameters None Return Value None Library Sacm S200 SC V e LIB Remark None 7 39 4 Function Resume paused SACM S200 speech Syntax C void SACM_S200_Resume void ASM call F SACH S200 Resume Parameters None Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark None 7 3 5 Function Change the volume of SACM S200 Syntax C void SACM S200 Vol me int Volume Index ASM R1 Volume Index cal F SAGM_S200 Volume Parameters Volume Index 0 15 0 Min volume 15 Max volume Return Value None Library lt Sacm_S200_SC_Vxxx LIB gt Remark None 7 3 6 Function Get the status of the SACM S200 module Syntax C unsigned int SACM S200 Status void ASM call F SACH S200 Status Retrun Value R1 Sunplus Technology Co Ltd PAGE 30 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 Parameters None Return Value bit 0 0 Speech ended 1 Speech Playing bit 1 15 Reserved Library Sacm S200 SC V e LIB
65. e Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH retf Sunplus Technology Co Ltd PAGE 35 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 8 API for SACM S480 S720 8 1 Hardware Dependent Function Initializes SACM S480 S720 8 1 1 Function Initialize SACM S480 S720 library Syntax C void SACM S490 Initial void ASM call F SACH S480 Initial Parameters None Return Value None Library lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB Remark 1 This function initializes the decoder of SACM S480 It also initializes the system clock Timer A DAC and enables the Timer AFIQ at 16KHz sample rate 2 The hardware setting is opened for user s reference see F SP SACM S480 Speed Init function in sacmvxxx asm 3 This function utilizes a register H InterruptStatus spce asm to work with user s program if for SPCE500A It uses P INT Mask instead if for SPCE 061A 060A 8 2 Service Loop Functions Service loop for SACM S480 decoding 8 2 4 Function Foreground service loop Syntax C void SACH S480 ServiceLoop void ASM call F SACM S480 ServiceLoop Parameters None Return Value None Library lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxx LIB Remark Foreground service loop has to be placed in mai
66. e is 0x8000 1 5mA or 1mA In order to avoid unnecessary power consumption we will set the output of current DAC to 0x0000 i e OMA when sound is not playing or especially before the system enters sleep If we set the DAC output from 0x8000 to 0x0000 suddenly a burst sound will be generated due to the sudden change of the DAC value Therefore we need to reduce DAC value from what it is to 0x0000 gradually and smoothly In other words the Ramp Down process Similarly before playing a sound whose data usually starts from 0x8000 users have to Ramp Up the current DAC from 0x0000 to 0x8000 gradually to avoid the burst sound a sound occurs suddenly without expectation There are mam methods to achieve Ramp Up Ramp Down process Here only we provide a Ramp Up Ramp Down method which is easy to be implemented Users can rewrite these Ramp Up Ramp Down f nctions using other methods 12 1 1 Function Ramp up DAC1 Syntax C void SP RampUpDACt void ASM call F SP RampUpDAC 1 Parameters None Return Value None Library sacmvxx asm Remark Programmers must stop sending data to DAC1 while executing this function Make sure there is no interrupt routine still sending data to DAC1now since it will destroy the process of DAC1 Ramp up process and probably cause noise usually burst sound to audio output 12 1 2 Function Ramp up DAC2 Syntax C void SP RampUpDAC 2 void ASM call F SP RampUpDAC2 Parameters No
67. e to buffer Syntax C N A ASM R1 the start address of buffer to write R2 the length of data call F_USER_A1600_GetData Parameters R1 the start address of buffer to write R2 the length of data Return Value User defined Library sacm_A1600_user asm Remark Sunplus Technology Co Ltd PAGE 24 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 3 This function is call back function for SACM A1600 library to read speech data from memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that library wants to get Example Play a SACM A1600 speech with Auto mode or Manual mode a In main c include sacmv40 h define Manual_Mode_Index 1 define Manual 0 define Auto 1 define DAC1 1 define DAC2 2 define Ramp_Up 1 define Ramp_Dn 2 int Mode int Speechindex 0 main Mode Auto Play mode setting if Mode Auto Auto mode play SACM A1600 Initial Initialization SACM A1600 Play Speechlndex DAC1 DAC2 Ramp_Up Ramp_Dn Play 1 speech While 1 SACM A1600 ServiceLoop Service loop for decode end of While 1 end of if Mode Auto if Mode Manual Manual mode
68. ervice loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allowe the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refer to Sunplus u nSP Assembly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP call F ISR Service SACM 480 Interrupt service routine HIE SACH S480 ServiceLoop ISR Background Service loop for SACM S480 playing push R1 to SP push function address to stack push SR to SP push SR to stack Rt FIQ TMA P INT Clear R1 reti 10 3 Playback Functions Playback control 10 3 1 Function Play a SACM MS01 melody Syntax C void SACM MSO01 Play int Speech Index int Channel int Ramp Set ASM R1 Speech Index Sunplus Technology Co Ltd PAGE 53 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 R2 Channel R3 Ramp_Set call F_SACM_S530_Play Parameters Speech Index 1 Manual Mode 0 max of speech index Auto Mode Channel 1 To DAC1 only 2 To DAC2 only 3 To both DAC1 and DAC2 Ramp Set 0 Disable both ramp up and down 1 Enable ramp up only 2 Enable ramp down only 3 Ena
69. f APIs for Auto mode and Manual mode while in SACM v40 library They share the same API architecture between Auto mode and Manual mode but controlled by the parameter of the playback API Please refer to the SACMxxxx API s description in the following chapters for details It is very convenient for users to develop their programs and easy to manage their projects Please note that in a project using SACM v40 user cannot include one algorithm with speed control Ex SACM S530 SC lib and the same algorithm without speed control Ex SACM_S530 lib simultaneously Sunplus Technology Co Ltd PAGE 9 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 Because they will have the same APIs only except speed control API and will not be able to compile successfully For example user cannot link SACM S480 V40 lib and SACM S480 V40 SC lib simultaneously in one project If users want to have speed control function in a project that originally do not have they just remove the original library SACM_XXXX_V40x lib which without speed control function and add the SACM XXXX SC V40x lib into the u nSP IDE and then you can use speed control API in your program Important The file format of SACM V40 library is different from SACMV32 Please use appropriate encoder tools Please refer to the following list Ugen Encode Tool SACM A1600 SACM DVR1600 DVR1600 exe DVR1600 exe SACM S480 S720 S485372C exe
70. ffer to write R2 the length ot data Return Value User defined Library sacm MSO01 user asm Remark 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 3 This function is call back function for SACM MS01 library to read speech data from memory storage Where H1 is the beginning address of internal buffer and R2 is the data length that library wants to get Example Play a SACM MS01 melody with Auto mode or Manual mode Sunplus Technology Co Ltd PAGE 58 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 a In main c include sacmv40 h define Manual_Mode_Index 1 define Manual 0 define Auto 1 define DAC1 1 define DAC2 2 define Ramp_Up 1 define Ramp_Dn 2 int Mode int Speechindex 0 main Mode Auto H Play mode setting if Mode Auto A Auto mode_play SACM_MS01_Initial H Initialization SACM MS01 Play Speechlndex DAC1 DAC2 Ramp_Up Ramp_Dn Play kb Speech While 1 SACM_MS01 ServiceLoop Service loop for decode end of While 1 end of if Mode Auto if Mode Manual Manual mode play SACM_MS01_Initial Initialization USER MS01_SetStartAddr SpeechIndex Set start address of speech data SACM_MS01_Play Manual_Mode_Index DAC1 DAC2 Ramp_Up Ramp_Dn
71. fined Library sacm S200 user asm Remark 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 7 5 2 Function Read the speech data from user s storage and write to buffer Syntax C N A ASM R1 the start address of buffer to write R2 the length of data call F USER S200 GetData Parameters Ri the start address of buffer to write R2 the length of data Return Value User defined Library sacm S200 user asm Sunplus Technology Co Ltd PAGE 33 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 2 Userimplements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM 3 This function is call back function for SACM S200 library to read speech data from memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that Remark 1 Manual mode use only FLASH library wants to get Example Play a SACM S200 speech with Auto mode or Manual mode a In main c include sacmv40 h define Manual_Mode_Index 1 define Manual 0 define Auto 1 define DAC1 1 define DAC2 2 define Ramp_Up 1 define Ramp_Dn 2 int Mode int Speechindex 0 main Mode Auto if
72. function F USER DVR1600 WriteData in sacm DVR1600 user asm to be implemented User can actually hook DVR1600 to various types of external memory storage for audio recording through the call back functions F SER DVR1600 WriteData and F USER DVR1600 GetData The DVR1600 can be viewed as the encoder of A1600 and thus user can use A1600 manual mode to playback DVR1600 recording Sunplus Technology Co Ltd PAGE 11 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 4 Service loop In new SACM library it supports both foreground and background service loops In the old fashion foreground service loop users have to put service loop in main Main loop will keep entering the service loop Inside the SACM service loop there will be a mechanism to determine if any task should be carried on Some overheads are produced inevitably The amount of overhead varies depends on the payload of CPU For background service loop the program checks if the service loop tasks should take place right after exiting interrupt It means program checks the demand for service loop tasks more efficiently and therefore grants users better flexibility to arrange user defined tasks in main Since the background Service loop eliminates some unnecessary overheads the background service loop programming can save more CPU resources and boost its throughput Both methods can facilitate building a SACM project by user Example Foreg
73. ibrary 1f a content of Ox2000 is in the R_InterruptStatus it means the Timer A FIQ is being Sunplus Technology Co Ltd PAGE 80 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 used by library subroutines at this moment For example the R InterruptStatus will be changed from 0x0000 to 0x2000 when SACM A1600 Play is called In contrast SACM A1600 Stop will not change the INT setting from 0x2000 to Ox0000 when SACM_A1600 is called Every interrupt setting must follow the rule to share the interrupt resource The following is an example to enable IRQ4 while SACM A1600 speech is playing R1 0 At beginning R_InterruptStatus 0x0000 call F_SACM_A1600_Play The R_InterruptStatus change to 0x2000 by F SACH A1600 Play TimerA FIQ enable and the speech playing if BODY TYPE SPCE061A R1 P INT Mask Get current interrupt setting status from P INT Mask if for SPCE040A 060A 061A endif if BODY TYPE SPCE500A R1 R_InterruptStatus Get current interrupt setting status from R InterruptStatus if for H SPCE120A 250A380A 500A endif Enable IRQ2 at thissmoment R1 0x0400 Set Timer BIRQ2 R_InterruptStatus R1 Update R InterruptStatus to 0x2400 P INT Ctrl R1 Setinterrupt control port 0x7010 For SPCE040A 060A 061 A 3 new hardware port P INT Mask 702DH serves the purpose as well and it is advised for users to take advantage of it In S
74. included SPCE port definition SACM related functions initializations queue and hardware dependent functions and SPCE dependent APIs For the purpose of modulization it is split since SACMv32 lib Hardware asm is now split and some header files are also arranged into 3 modules 1 spce inc SPCE port definition spce asm R_InterruptStatus for SPCE500A to keep tack of interrupt setting status 2 sacmVnn asm Library initializations queue functions and ramp up down hardware dependent functions sacmVnn h C function declarations for SACM APIs xxxx inc s200 inc s480 inc s530 inc a1600 inc ms01 and DVR1600 inc Assembly function declarations for each algorithm 3 sp lib asm General APIs for SPCE key scan and HO configuration function Sunplus Technology Co Ltd PAGE 75 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 13 2 Step by step procedure For a programmer to update old projects to under new SACM library structure the procedures are 1 Find each line include hardware inc inside assembly files in project 2 Check the files where the line include hardware inc presents 2 1 If SPCE port definition is used in the module then add include spce inc on the top of the file 2 2 If any key function is used in the module then add include sp lib inc on the top of the file 2 3 If any SACM library function is used in the module then add include xxxx inc
75. l v3 0 EX R1 C SystemClock CPU Clock setting IP SystemClock R1 R1 0x0030 TimerA CKA Fosc 2 CKB 1 Tout off P_TimerA_Ctrl R1 R12 C_MS01_Timer_Setting TimerA setting P_TimerA_Data R1 R1 0x0002 Disable ADC disable MIC_In P_ADC_Ctrl R1 R1 0x00A0 Latch DAC1 by Timer A Latch DAC2 by Timer A P DAC Ctrl R1 R1 Oxffff P INT Clear R1 Clear interrupt occupied events if BODY TYPE SPCE061A R1 P INT Mask endif if BODY TYPE SPCE500A R1 R_InterruptStatus endif R1 C FIQ TMA Enable Timer B FIQ R_InterruptStatus R1 P_INT_Ctrl Rt retf Step 4 In order to play two algorithms simultaneously and correctly the service loop routines of MS01 and A1600 are set according to user s choice in step1 EX _FIQ push R1 R5 to SP R1 C_FIQ_TMA test R1 P_INT_ Ctrl jne L_FIQ_TimerA Timer A FIQ entrance R1 C_FIQ_TMB test R1 P_INT_Ctrl Sunplus Technology Co Ltd PAGE 84 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 jne L FIQ TimerB Timer B FIQ entrance L FIQ TimerA hook Timer A FIQ subroutine here and define it to be external call F ISR Service SACM A1600 A1600 FIQ TMA Service call F ISR Service SACM MS01 MS01 FIQ TMA Service R1 F SACH A1600 ServiceLoop ISR Background Service loop for SACM1600 push R1 to SP push SR to SP R1 C_FIQ_TMA P IN
76. lock Timer A DAC and enables the Timer A FIQ at the sample rate on 16KHz 2 The hardware setting is opened for user s reference see F SP SACM MS90 1 Init function in sacmvxxx asm 3 This function utilizes a register R_InterruptStatus spce asm to work with user s program for SPCE500A It uses P INT Mask instead for SPCE 061A 060A 10 2 Service Loop Functions Service loop for SACM MS01 decoding 10 2 1 Function Foreground service loop Syntax C void SACH MS01 ServiceLoop void ASM call F SACH MSO01 ServiceLoop Parameters None Return Value None Library lt Sacm_MS01_Vxxx LIB gt Remark Foreground service loop has to be placed in main loop 10 2 2 Function Background service loop Syntax Q N A Sunplus Technology Co Ltd PAGE 52 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 ASM Call F SACM MSO01 ServiceLoop ISR Parameters N A Return Value N A Library lt Sacm_MS01_Vxxx LIB gt Remark 1 Background service loop is placed in either FIQ or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the MS01 code is allocated in page 0 to assure that program flow can proceed to F SACM MS01 ServiceLoop ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background s
77. must add Cmacro lib in library modules Sunplus Technology Co Ltd PAGE 77 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 14 3 Adding resources For adding new resources user can click on the resource tab in the workspace window and add in the resource from the file dialogue popped up Then check out the resource asm for the speech table for SACM library and edit the speech sequence for users application ps Edit view Project Build Tools Window Help j amp lxl E d ER arno cs RS bss sotstatadd Z 9 il 8 85 95 t e Olek Ir mee wcoo Hi ses mE Um A1 S CH 8480 algorithm with play stop pause resume volume up volume down function By Sam Sung Wodified by Ray Cheng Platform SPCEOG1A unSP IDE 1 12 0 Windows 2000 Gast modified date 2 ip i Pr n Ge 2003 10 22 iFirst version General Function call void System_Initial void For Hardware Reyboard scan see system asm in detail void System ServiceLoop void For Reyboard scan see system asm in detail i ff Standard Function call int 8P Getth void Return values of SP Getth 0x00 0x01 0x02 0x04 0x08 0x10 0x20 0x40 0x80 Function call for SACH Speed only Syntax void SACM XOX Initial void BACH 200 Play int Speech Index int Channel int Ramp Set ii Snaarch Tndaw Aid source 8 eve BR
78. n Block data can be a word a byte or an array Description This function called by library to fetch data blocks for playback The Library needs a data block specified by R1 the start address and R2 the length of the block Uaser would have to compose the function body based on the storage type to fulfill this demand from library Jesse F USER MS01 GetData proc Sunplus Technology Co Ltd PAGE 88 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 user implement this interface to get external data push R1 R4 to SP SR R_Resouce_DS R3 R_Resouce_BS L Get Loop cmp R2 0 jz L End R4 D R3 R1 R4 R2 1 cmp R3 0 jnz L_Get_Loop SR 0x0400 R_Resouce_DS SR jmp L_Get_Loop L_End R_Resouce_BS R3 pop R1 R4 from SP retf endp Step 3 Modified the parameter setting inysacmv40 asm First check F SP SACM A1600 Init a Set the P_SystemClock in Sacm A1600 Init to choose system clock b Because A1600 service loop is on FIQ timer A select the clock source of timer A in P TimerA Ctrl and timer setting in P TimerA Data C Turn off ADC and Mic by setting P ADC Ctrl if not use d Assign DAC channels to your speech and melody For example if user wants to play A1600 on DAC1 and melody on DAC2 user shall write OxOOAO to P DAC Ctrl e Enable timer A FIQ for A1600 service loop Below is an example of ini
79. n loop 8 2 2 Function Background service loop Syntax Q N A Sunplus Technology Co Ltd PAGE 36 March 30 2004 amp sUNPLUS ASM Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 Call F SACM S480 ServiceLoop ISR N A N A lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB 1 Background service loop is placed in either FIQ or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the S480 code is allocated in page 0 to assure that program flow can proceed to F SACM S480 ServicelLoop ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background service loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allowe the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refer to Sunplus u nSP Assembly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP call F ISR Service SACM 480 Interrupt service routine HIE SACH S480 ServiceLoop
80. ne Return Value None Library sacmvxx asm Remark Programmers must stop sending data to DAC2 while executing this function Make sure there is Sunplus Technology Co Ltd PAGE 71 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 no interrupt routine still sending data to DAC1now since it will destroy the process of DAC1 ramp up process and probably cause noise usually burst sound to audio output 12 1 3 Function Ramp down DAC1 Syntax C void SP_RampDnDAC1 void ASM call F SP RampDnDAC1 Parameters None Return Value None Library sacmvxx asm Remark Programmers must stop sending data to DAC1 while executing this function Make sure there is no interrupt routine still sending data to DAC1now since it will destroy the process of DAC1 Ramp up process and probably cause noise usually burst sound to audio output 12 1 4 Function Ramp down DAC2 Syntax C void SP RampDnDAC2 void ASM call F SP RampDnDAC2 Parameters None Return Value None Library sacmvxx asm Remark Programmers must stop sending data to DAC2 while executing this function Make sure there is no interrupt routine still sending data to DAC1now since it will destroy the process of DAC1 Ramp up process and probably cause noise usually burst sound to audio output 12 2 AD DA Function 12 2 1 Function Switch SPCE ADC channel for recording Syntax C void SP Swit
81. oreground service loop has to be placed in main loop 11 2 2 Function Background service loop Syntax C ASM Parameters Return Value Library Remark N A Call F SACM DVR1600 ServiceLoop ISR None None lt Sacm_DVR1600_Vxxx LIB gt lt Sacm_DVR1600_SC_Vxxx LIB gt Background service loop is placed in either FIQ or IRQ and it must be placed before leaving the FIQ or IRQ Please refer to the following example 2 Please make sure that the DVR1600 code is lt allocated in page 0 to assure that program flow can proceed to F SACM DVR1600 ServiceLoop ISR correctly 3 This background service loop will pop the R1 R5 register Program does not have to pop the registers before reti 4 The advantage users can get from background service loop is that program can reduce unnecessary overhead in main and as a result program can yield better performance in terms of throughput 5 Example By this manner of programming the program allows the background service loop to take place right after leaving the FIQ IRQ and meanwhile the next interrupt can still intrude the service loop even when the background service loop is still running Please refersto Sunplus u nSP Assembly Tools User Manual for the detail of the argument passing in library routine _FIQ push R1 R5 to SP cal F 4SR Service SACM DVR1600 Interrupt service routine R1 F SACM DVR1600 ServiceLoop_ISR Background Service loop for SACM A1600
82. rithm supported by SPCE Due to the RAM size and CPU speed limitations some SPCE series cannot support all SACM algorithms The following table shows the available SACM algorithm to SPCE series Algorithm SPCE500A 380A 250A 120A SPCE040A 060A 061A SPCE1070A 1080A SACM A1600 YES YES YES SACM A1600 SC NO YES NO SACM S530 YES YES YES SACM S530 SC NO YES NO SACM S480 S720 YES YES YES SACM S480 S720 SC NO YES NO SACM S200 SC NO YES NO SACM MS01 YES YES YES SACM DVR1600 NO YES NO SACM DVR1600 SC NO YES NO 2 4 Difference between SACM V40 and SACM V32 Unlike SACM v32 which includes several libraries as a whole the SACM v40 library is separated into 10 subsets and each corresponds to a different SACM algorithm That is each of these subsets is an individual SACM library You just include whatever you need into your program project They are SACM A1600 V40a lib SACM A1600 SC V40a lib SACH S530 V40a lib SACM S530 SC V40a lib SACH S480 V40alib SACM S480 SC V40a lib SACM S200 SC V40a lib SACM_MS01_V40a lib SACM DVR1600 V40a lib and SACM DVR1600 SC V40a lib where SC means Speed Control You can change the playing speed without altering the pitch of the sound That is A1600 S480 S530 S200 and DVR1600 support speed control function SACM V40 library adds DVR1600 A1600 encoder and decoder but removes the S240 A2000 A3200 and DVR A2000 encoder For SACM v32 there are different sets o
83. rn Value Library Remark void SACM_DVR1600_lnitial void call F_SACM_DVR1600_Initial None None lt Sacm_DVR1600_Vxxx LIB gt Sacm DVR1600 SC Vxxx LIB gt 1 This function initializes the decoder of SACM DVR1600 It also initializes the system clock Timer A DAC and enables the Timer AFIQ at the sample rate on 16KHz 2 The hardware setting is opened for user s reference see F SP SACM DVR1600 Init in sacmvxxx asm 3 This function utilizes a register H InterruptStatus spce asm to work with user s program for SPCE500A It uses P INT Mask instead for SPCE 061A 060A 4 In SACM DVR1600 the external memory module is required to store the recording data External memory module can apply GPIO or Sunplus serial interface to connect to external memory The memory access interface must implement the F USER DVR1600 GetData F USER DVR1600 WriteData and User DVR1600 SetStartAddr in sacm DVR1600 user asm 5 lt The decode engine is the same as that of SACM A1600 11 2 Service Loop Functions S Service loop for SACM DVR1600 decoding 11 2 1 Function Foreground service loop Syntax Q ASM Parameters Return Value Library void SACM_DVR1600_ServiceLoop void call F_SACM_DVR1600_ServiceLoop None None lt Sacm_DVR1600_Vxxx LIB gt lt Sacm_DVR1600_SC_Vxxx LIB gt Sunplus Technology Co Ltd PAGE 61 March 30 2004 amp sUNPLUS Remark SPCE SACM Library User s Manual v3 0 F
84. round service loop In main c int main System_Initial SACM_A1600_Initial SACM_A1600_Play 0 DAG1 DAC2 Ramp_Up Ramp_Dn while 1 System_ServiceLoop Service loop for watchdog clear SACM A1600 ServiceLoop Foreground Service loop LU end of while 1 return 0 end of main In isr asm _FIQ push R1 R5 to SP save registers call F ISR Service SACM A1600 interrupt service routine R12C FIQ TMA clear interrupt Sunplus Technology Co Ltd PAGE 12 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 P INT Clear R1 pop R1 R5 from SP restore registers reti Background service loop In main c int main System_Initial SACM A1600 Initial SACM A1600 Play 0 DAC1 DAC2 Ramp Up Ramp Dn while 1 System_ServiceLoop Service loop for watchdog clear end of while 1 return 0 end of main In isr asm _FIQ push R1 R5 to SP save registers call F ISR Service SACM A1600 interrupt service routine If eessen En eessen R1 F_SACM_A1600 ServiceLoop ISR Get function Address of background service loop It restores registers r1 r5 internally push R1 to SP push address to stack for PC to refer push SR to SP push SR to stack R1 C FIQ TMA clear interrupt P INT Clear R1 reti Sunplus Technology Co Ltd PAGE 13 March 30 2004 amp
85. rs for concurrent algorithms The real time issue is about the service loop and ISR In each algorithm certain decode process has to be carried out in a certain of period If the decode process cannot be executed successfully it will cause malfunction of algorithm User has to refer to the service loop timing requirement information in the appendix It is advised that for the concurrent algorithm applications user can use one foreground service loop and one background service loop to allow the background service loop to be executed timely If user chose both to be with foreground service loop user is advised to handle the service loop sequence with discretion After the evaluation based on real time and resource issues user may still need to try the possible combinations for optimal presentation of the SACMvalgorithms Instructions Auto Mode MS01 A1600 In SPCE060 061 SACM MS01 can play with other algorithms such as A1600 S200 S480 and S530 Below is an example showing how to play ms01 and A1600 background simultaneously Step 1 Decide what FIQ or IRQ service routine your service loop want to hooks on It is suggested that hooks your ms01 service loop and A1600 service loop on FIQ Timer A at the same interrupt frequency Step 2 Modified the parameter setting in sacmv40 asm First check F SP SACM A1600 Init a Set the P SystemClock in Sacm A1600 Init to choose system clock Sunplus Technology Co Ltd P
86. rupt setting 11 3 4 Function Pause currently playing SACM DVR1600 speech Syntax C void SACM DVR1600 Pause void Sunplus Technology Co Ltd PAGE 64 March 30 2004 amp sUNPLUS ASM Parameters Return Value Library Remark SPCE SACM Library User s Manual v3 0 call F SACM DVR1600 Pause None None lt Sacm_DVR1600_Vxxx LIB gt Sacm DVR1600 GC Vxxx LIB None 11 3 5 Function Resume paused SACM DVR1600 speech Syntax Q ASM Parameters Return Value Library Remark void SACM_DVR1600_Resume void Call F_SACM_DVR1600_Resume None None lt Sacm_DVR1600_Vxxx LIB gt Sacm DVR1600 SC V x LIB None 11 3 6 Function Change the volume of SACM DVR1600 Syntax C ASM Parameters Return Value Library Remark void SACM DVR1600 Volume int Volume Index R1 Volume Index call F SACM DVR1600 Volume Volume Index 0 15 0 Min volume 15 Max volume None Sacm DVR1600 Vxxx LIB s Sacm DVR1600 GC Vxxx LIB None 11 3 7 Function Get the status from SACM DVR1600 module Syntax C ASM Parameters Return Value unsigned int SACM DVR1600 Status void call F SACM DVR1600 Status Retrun Value R1 N A bit 0 0 Stop 1 Recording Sunplus Technology Co Ltd PAGE 65 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 bit 1 0 Stop 1 Playing bit
87. s not Play executed Inte vuptsService Routine Service Loop Background Fetch data from memory Manual mode Service tasks processed Interrupt Service Routine Timing diagram Manual mode Background service loop OOO OUUU MO OUa OM Sunplus Technology Co Ltd PAGE 16 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 5 Memory Allocation For each SACM algorithm it is necessary to use a size of RAM blocks for encoding or decoding purposes The RAM space taken can be shared among algorithms or with user application by aligning the RAM blocks manually The memory allocation manifest can be found as the name project name map in the directory release or debug The u nSP IDE v1 6 or later also provides a convenient tool memory map to graphically list the memory space taken by each module section public function and variable The principle of sharing RAM is that as long as the algorithms or applications are not active simultaneously The RAM block can be shared through ORAM or OSRAM section declaration For details of RAM ORAM OSRAM section please refer to Sunplus u nSP Assembly Tools User s Manual If user plans to build an application with both speech S200 S480 or S530 and background music MS01 up and running at the same time the RAM allocation would also have to be separated as the section names suggest
88. sUNPLUS SPCE SACH Library User s Manual v3 0 For SACMV40 Foreground Service Loop Background Service Loop S200 YES YES 480 S720 YES YES 480 S720 SC YES YES S530 YES YES 530 SC YES YES A1600 YES YES A1600 SC YES YES DVR1600 YES NO DVR1600 SC YES NO MS01 YES YES main c sacmVnn lib sacm asm sacm XXXX user asm isr asm Hardware Initialization Initialization Play Service Loop Foreground Service tasks processed Service Loop Service Foreground tasks not executed Service Loop Foreground Service tasks not executed Service Loop Foreground Service tasks not executed Service Loop Foreground Service tasks processed Inte Inte Inte Inte rupt Service Routine Tupt Service Routine rupt Service Routine Tupt Service Routine Timing diagram Auto mode Foreground service loop Sunplus Technology Co Ltd PAGE 14 March 30 2004 amp sUNPLUS main c sacmVnn lib sacm asm sacm XXXX user asm Hardware Initialization Initialization Interrupt Service Routine Service Loop Sani b ervice Foreground tasks not Play executed Fetch data from memory Manual mode Service Loop eoerreeoe u o Foreground Service emm pi Co tasks processed Interrupt Service Routine Service Loop Foreground Fetch
89. ser asm manual mode only USER DVHR1600 SetStartAddr defined by user F USER DVR1600 SetStartAddr are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g SRAM FLASH retf F USER DVR1600 GetData defined by user F USER DVR1600 GetData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g SRAM FLASH retf F USER DVR1600 WriteData defined by user F USER DVR1600 WriteData are Manual mode use only User implements this function based on the storage type The memory interface has to be constructed in advance if user intends to access the data fromeexternal storage e g SRAM FLASH retf A G c J B c M KG Sunplus Technology Co Ltd PAGE 70 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 12 Hardware dependence API in SACMVxx asm Open source 12 4 Ramp Functions In current type DAC the digital input range is 0x0000 0xFFFF and the corresponding result analog range is 0 3mA or 2mA by setting The middle valu
90. t in sacmvxxx asm must also be updated as well Syntax C N A ASM call F ISR Service SACM A1600 Parameters None Return Value None Library lt Sacm_A1600_Vxxx LIB gt Sacm A1600 SC V xx LIB Remark 1 This function is used in assembly only and it can be hooked on the _FIQ IRQ1 or IRQ2 label See isr asm for details 2 The F ISR Service SACM A1600 will not take up any time to process the Interrupt routine except minor overheads if the program is not playing It is possible for users to place user define function in the same FIQ or IRQ Sunplus Technology Co Ltd PAGE 23 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 EX FIQ push R1 R5 to SP call F ISR Service SACM A1600 call F User ISR R12C IRQ1 TMA P INT Clear R1 pop R1 R5 from SP reti 6 5 User Functions for SACM A1600 playback in manual mode 6 5 1 Function Set start address for SACM A1600 speech data Syntax C USER A1600 SetStartAddr ASM call F USER A1600 SetStartAddr Parameters User defined Return Value User defined Library sacm_A1600_userasm Remark 1 Manual mode use only 2 User implements the function based on the storage type The memory interface has to be constructed in advance if user intends to access the data from external storage e g ROM FLASH 6 5 2 Function Read the speech data from user s storage and writ
91. te approximate ISPCE500A at 24 MHz A1600 52 58 8KHz 5 3Kbps 75 10KHz 6 6Kbps N A 12KHz 7 9Kbps SPCE061A at 24M Hz 38 46 8KHz 5 3Kbps 56 10KHz 6 6Kbps 65 12KHz 7 9Kbps 35 8KHz 4 8Kbps 39 8KHz 7 2Kbps SPCE061A at 49 MHz 19 21 8KHz 5 3Kbps 28 10KHz 6 6Kbps 34 12KHz 7 9Kbps 20 8KHz 4 8Kbps 21 8KHz 7 2Kbps pase 52 8KHz 7 2Kbps Song wa P NSM Man 67 1Ch 16KHz 50 1Ch 916KHz 24 1Ch 16KHz 78 2Ch 16KHz 59 2Ch 16KHz 28 2Ch 16KHz 88 3Ch 16KHz 68 3Ch 16KHz 31 3Ch 16KHz N A 4ChQ16KHz 76 4Ch 16KHz 36 4Ch 16KHz 16 5 TABLE 5 Timing Limitation approximate Service Loop Time Limit A1600 530 7 5 ms 5 3Kbps 6 0 ms 6 6Kbps 5 0 ms 7 2Kbps Note 1 The number is the maximum interval in which the program have to execute service loop These figures are measured with SACM v40 library 2 For example the F SACM A1600 ServiceLoop must be called each 16ms in user s main loop Otherwise It Sunplus Technology Co Ltd PAGE 94 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 may cause noise to audio output main SACM_A160_Initial SACM_A1600_Play 0 3 3 While 1 User_Function SACM A1600 ServiceLoop Go here in each 16ms 16 6 TABLE 6 Name of Overlap RAM in the library Table Name and size of Overlap RAM in the library Overlap RAM definition Algorithm Grerptpa Labe Size word OVERLAP_DV
92. tial A1600 EX F SP SACM A1600 Init R1 C SystemClock CPU Clock setting IP SystemClock R1 R1 0x0030 TimerA CKA Fosc 2 CKB 1 Tout off P_TimerA_Ctrl R1 R12 C A1600 Timer Setting TimerA setting EEN Sunplus Technology Co Ltd PAGE 89 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 IP TimerA Data R1 R1 0x0002 Disable ADC disable MIC In P ADC Ctrl R1 R1 2 0x00A0 Latch DAC1 by Timer A Latch DAC2 by Timer A P DAC Ctrl Rt R1 Oxffff P INT Clear R1 Clear interrupt occupied events if BODY TYPE SPCE061A R1 P INT Mask endif if BODY TYPE SPCE500A R1 R InterruptStatus endif R1 C FIQ TMA Enable Timer B FIQ R_InterruptStatus R1 P INT Ctrl R1 retf Step 4 Check the F SP SACGM MSO1 Init Tor system clock and timer A setting F SP SACM MSO1 Init EX R1 C_SystemGlock CPU Clock setting IP SystemClock R1 R1 2 0x0030 TimerA CKA Fosc 2 CKB 1 Tout off P_TimerA_Ctrl R1 R1 C_MS01_Timer_Setting TimerA setting P_TimerA_Data R1 R1 0x0002 Disable ADC disable MIC_In P_ADC_ Ctrl R1 R1 0x00A0 Latch DAC1 by Timer A Latch DAC2 by Timer A P DAC Ctrl Rt R1 Oxffff P_INT_Clear R1 Clear interrupt occupied events Sunplus Technology Co Ltd PAGE 90 March 30 2004 amp sUNPLUS SPCE SACM Library User s
93. ucted in advance if user intends to access the data from external storage e g ROM FLASH 3 This function is call back function for SACM S530 library to read speech data from memory storage Where R1 is the beginning address of internal buffer and R2 is the data length that library wants to get Example Play a SACM S530 speech with Auto mode or Manual mode a In main c include sacmv40 h define Manual_Mode_Index 1 define Manual 0 define Auto 1 define DAC1 1 define DAC2 2 define Ramp_Up 1 define Ramp_Dn 2 int Mode int Speechlndex 0 main Mode Auto Play mode setting if Mode Auto Auto mode play SACM S530 Initial Initialization SACM_S530_Play SpeechIndex DAC1 DAC2 Ramp Up Ramp Dn Play 17 speech While 1 SACM S530 ServiceLoop Service loop for decode end of While 1 end of if Mode Auto if Mode Manual Manual mode play Sunplus Technology Co Ltd PAGE 50 March 30 2004 amp sUNPLUS SPCE SACH Library User s Manual v3 0 SACM S530 Initial Initialization USER_S530_SetStartAddr SpeechIndex Set start address of speech data SACM_S530_Play Manual_Mode_Index DAC1 DAC2 Ramp_Up Ramp_ Dn Manual mode play speech SACM S530 ServiceLoop Service loop for decode end of SACM S530 Play end of if Mode Manual end of main b In ism asm FIQ push R1 R5 to SP push registers call F
94. unction Change voiced index of SACM 8200 eese ener 32 7 4 ISR FUNCTIONS INTERRUPT SERVICE ROUTINE FOR SACM S200 sss 32 7 5 USER FUNCTIONS FOR SACM S200 PLAYBACK IN MANUAL MODE eene 33 7 5 1 Function Set start address for SACM S200 speech dato 33 7 5 2 Function Read the speech data from user s storage and write to buffer 33 8 APT FOR SNO DEU E X M 36 8 1 HARDWARE DEPENDENT FUNCTION INITIALIZES SACH GADOIG 20 36 6 1 1 Function Initialize SACM S480 8720 library eese 36 8 2 SERVICE LOOP FUNCTIONS SERVICE LOOP FOR SACM S480 DECODING eee 36 amp 2 1 Function Foreground service Joen 36 8 2 2 Function Background service Joen 36 8 83 PLAYBACK FUNCTIONS PLAYBACK CONTROL esses nnne nen nnn nnn nnn nnn nennen innen 37 6 3 1 Function Play a SACM S480 8720 speech 37 8 3 2 Function Stop playing SACM 8S480 8720 speech 38 8 3 3 Function Pause playing SACM S480 S720 speech 39 8 3 4 Function Resume paused SACM 8S480 8720 speech 39 6 3 5 Function Change the volume of SACM 8480 8720 cessent ene 39 8 3 6 Function Get the status of the SACM S480 S720 module eee 39 Sunplus Technology Co Ltd PAGE 3 March 30 2004 amp sUNPLUS SPCE SACM Library User s Manual v3 0 6 3 7 Function Change the speed index of SACM 8480 8720 essere 40 8 4 ISR FUNCTIONS IN
95. xxx LIB Remark None 8 3 6 Function Get the status of the SACM S480 S720 module Syntax C unsigned int SACM S480 Status void ASM call F SACM S480 Status Sunplus Technology Co Ltd PAGE 39 March 30 2004 amp sUNPLUS Parameters Return Value Library Remark SPCE SACH Library User s Manual v3 0 Retrun Value R1 None bit 0 0 Speech ended 1 Speech Playing bit 1 15 Reserved lt Sacm_S480_Vxxx LIB gt Sacm S480 SC Vxxx LIB None 8 3 7 Function Change the speed index of SACM S480 S720 Syntax Q ASM Parameters Return Value Library Remark void SACM S480 Speed int Speed Index R1 Speed Index call F SACM S480 Speed Speed Index 12 12 0 Normal speed 12 Min speed 12 Max speed None Sacm 8480 SC_Vxxx LIB gt Min speed Speed Index 12 is 1 2 of Normal speed Speed Index 0 Max speed Speed _ Index 12 is twice of Normal speed 8 4 ISR Functions Interrupt service routine for SACM S480 S720 This routine will get the decoded data from service loop subroutine and send data to DAC for playing It can be placed in FIQ or ARQA or JIRQ2 depending on Timer used The initial function F SP SACH S480 Init in sacmvxxx asm must also be updated as well Syntax C ASM Parameters Return Value Library Remark N A call F ISR Service SACM S480 None None lt Sacm_S480_Vxxx LIB gt
Download Pdf Manuals
Related Search
Related Contents
Samsung SP-M205W Felhasználói kézikönyv LC-Power LC6460GP3 V2.3 power supply unit 右ボード取り外し Kit 取扱説明書 ⅯSⅮS受領書 FAXNo.052-443-4825 DVD-311HDMI Buffalo TeraStation Pro Duo 4TB 取扱説明書 / Instruction Manual / Bedienungsanleitung / 使用说明书 L`office du juge et le déploiement dans le temps des AC 80 User's Manual Copyright © All rights reserved.
Failed to retrieve file