///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR ANSI C/C++ Compiler V6.30.1.53127/W32 for ARM    08/Mar/2012  18:18:27 /
// Copyright 1999-2011 IAR Systems AB.                                        /
//                                                                            /
//    Cpu mode     =  thumb                                                   /
//    Endian       =  little                                                  /
//    Source file  =  D:\Profiles\b01252\My Documents\Freescale\P0\software\s /
//                    ample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_ /
//                    sc\src\projects\TWRK20D50M_Demo\buzzer\buzzer.c         /
//    Command line =  "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\src\projects\TWRK20D50M_Demo\buzzer\buzzer.c" -D    /
//                    IAR -D TOWER -D TWR_K20D50M -lCN                        /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\" /
//                     -lB "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\" -o          /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\FLASH_128KB_PFLASH\Obj\"  /
//                    --no_cse --no_unroll --no_inline --no_code_motion       /
//                    --no_tbaa --no_clustering --no_scheduling --debug       /
//                    --endian=little --cpu=Cortex-M4 -e --fpu=None           /
//                    --dlib_config "C:\Program Files\IAR Systems\Embedded    /
//                    Workbench 6.0_5\arm\INC\c\DLib_Config_Normal.h" -I      /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\common\" -I  /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\cpu\" -I     /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\cpu\headers\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\uart\" -I        /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\drivers\mcg\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\wdog\" -I        /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\drivers\rcm\ /
//                    " -I "D:\Profiles\b01252\My                             /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\drivers\lptmr\" -I       /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\platforms\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\" -I                /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\projects\TWR /
//                    K20D50M_Demo\" -I "D:\Profiles\b01252\My                /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \dma\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \adc16\" -I "D:\Profiles\b01252\My                      /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \i2c\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \tsi\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \adc_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \angle_calculation\" -I "D:\Profiles\b01252\My          /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \buzzer\" -I "D:\Profiles\b01252\My                     /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \fft_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \irda_test\" -I "D:\Profiles\b01252\My                  /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \cmt_test\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \protocol\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \task_mgr\" -I "D:\Profiles\b01252\My                   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \TWRK20_specific\" -I "D:\Profiles\b01252\My            /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\projects\TWRK20D50M_Demo /
//                    \rtc\" -I "D:\Profiles\b01252\My                        /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Lib\Lib\interm /
//                    ediateFiles\" -I "D:\Profiles\b01252\My                 /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Lib\Include\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4 /
//                    \DeviceSupport\ARM\ARMCM4\" -I "D:\Profiles\b01252\My   /
//                    Documents\Freescale\P0\software\sample code             /
//                    cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\build\ia /
//                    r\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4\CoreSupport\"  /
//                    -I "D:\Profiles\b01252\My Documents\Freescale\P0\softwa /
//                    re\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50 /
//                    MHz_sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\CM4 /
//                    \CoreSupportLiker Options-Library\" -I                  /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\src\CMSIS\DSP_Li /
//                    b\Lib\intermediateFiles\arm_cortexM4_math.lib\" -I      /
//                    "D:\Profiles\b01252\My Documents\Freescale\P0\software\ /
//                    sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz /
//                    _sc\build\iar\TWRK20D50M_Demo\..\..\..\build\" -Ol      /
//                    --use_c++_inline -I "C:\Program Files\IAR               /
//                    Systems\Embedded Workbench 6.0_5\arm\CMSIS\Include\"    /
//                    -D ARM_MATH_CM4                                         /
//    List file    =  D:\Profiles\b01252\My Documents\Freescale\P0\software\s /
//                    ample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_ /
//                    sc\build\iar\TWRK20D50M_Demo\FLASH_128KB_PFLASH\List\bu /
//                    zzer.s                                                  /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME buzzer

        #define SHT_PROGBITS 0x1

        EXTERN clap_peak_energy
        EXTERN enable_irq

        PUBLIC C_MAJ_SCALE
        PUBLIC MONOCHROMATIC_SCALE
        PUBLIC PIT_init
        PUBLIC base_time125m
        PUBLIC beep
        PUBLIC buzzer_ftm_init
        PUBLIC buzzer_off
        PUBLIC buzzer_on
        PUBLIC echo_flag
        PUBLIC max_value
        PUBLIC pit1_isrv
        PUBLIC set_out_module
        PUBLIC ti_accel_sampling
        PUBLIC ti_beep
        PUBLIC ti_delay
        PUBLIC ti_echo
        PUBLIC ti_fall
        PUBLIC ti_max_value
        PUBLIC ti_pause
        PUBLIC ti_test_adc
        PUBLIC ti_test_leds
        PUBLIC ti_tone
        PUBLIC ti_tone_wait
        PUBLIC tone
        PUBLIC tone_enable

// D:\Profiles\b01252\My Documents\Freescale\P0\software\sample code cesar\TWR-K20D50M_LABS_AND_CE\kinetis_50MHz_sc\src\projects\TWRK20D50M_Demo\buzzer\buzzer.c
//    1 /****************************************************************************************************/
//    2 /**
//    3 Copyright (c) 2011 Freescale Semiconductor
//    4 Freescale Confidential Proprietary
//    5 \file      buzzer.c
//    6 \brief     Buzzer is based on a FTM and one channel,  also it uses and PIT for timer control  
//    7 \author     
//    8 \author     
//    9 \version    1.0
//   10 \date       Sep 26, 2011
//   11 */
//   12 
//   13 #include "common.h"
//   14 #include "buzzer.h"
//   15 #include "fft_test.h"
//   16 #define SWEEP_START_PER  3000
//   17 #define SWEEP_END_PER     500
//   18 
//   19 

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
//   20 uint32 ti_delay;
ti_delay:
        DS8 4

        SECTION `.bss`:DATA:REORDER:NOROOT(2)
//   21 uint32 ti_accel_sampling;
ti_accel_sampling:
        DS8 4

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   22 uint16 ti_tone;
ti_tone:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   23 uint16 ti_pause;
ti_pause:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   24 uint16 ti_beep;
ti_beep:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   25 uint16 ti_fall;
ti_fall:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   26 uint16 ti_tone_wait;
ti_tone_wait:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
//   27 uint8 base_time125m;
base_time125m:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   28 uint16 ti_test_leds;
ti_test_leds:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   29 uint16 ti_test_adc;
ti_test_adc:
        DS8 2
//   30 
//   31 
//   32 

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   33 uint16 ti_max_value;
ti_max_value:
        DS8 2

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   34 int16 max_value;
max_value:
        DS8 2
//   35 
//   36 

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
//   37 uint8  tone_enable; 
tone_enable:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(0)
//   38 char echo_flag;
echo_flag:
        DS8 1

        SECTION `.bss`:DATA:REORDER:NOROOT(1)
//   39 uint16 ti_echo;
ti_echo:
        DS8 2
//   40 
//   41 const uint16 MONOCHROMATIC_SCALE[];
//   42 
//   43 
//   44 /**   buzzer_ftm_init
//   45  * \brief    Initialize Periodic interrupt timer,
//   46  * \brief    PIT1 is used for tone/buzzer time control
//   47  * \author   b01252
//   48  * \param    none
//   49  * \return   none
//   50  */  

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   51 void buzzer_ftm_init(void)
//   52 {
buzzer_ftm_init:
        PUSH     {R7,LR}
//   53    SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;
        LDR.N    R0,??DataTable7  ;; 0x40048038
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x800
        LDR.N    R1,??DataTable7  ;; 0x40048038
        STR      R0,[R1, #+0]
//   54    SIM_SCGC6|=(SIM_SCGC6_FTM0_MASK);   
        LDR.N    R0,??DataTable7_1  ;; 0x4004803c
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x1000000
        LDR.N    R1,??DataTable7_1  ;; 0x4004803c
        STR      R0,[R1, #+0]
//   55    PORTC_PCR4 = (0|PORT_PCR_MUX(4)); /* FTM0_CH0 enable on PTC3 */
        LDR.N    R0,??DataTable7_2  ;; 0x4004b010
        MOV      R1,#+1024
        STR      R1,[R0, #+0]
//   56    FTM0_MOD  = 10000;  /* 0x0063 / 25MHz = 4uS PWM period */
        LDR.N    R0,??DataTable7_3  ;; 0x40038008
        MOVW     R1,#+10000
        STR      R1,[R0, #+0]
//   57    FTM0_C3SC = 0x28;   /* No Interrupts; High True pulses on Edge Aligned PWM */
        LDR.N    R0,??DataTable7_4  ;; 0x40038024
        MOVS     R1,#+40
        STR      R1,[R0, #+0]
//   58    FTM0_C3V  =  5000;  /* 90% pulse width */
        LDR.N    R0,??DataTable7_5  ;; 0x40038028
        MOVW     R1,#+5000
        STR      R1,[R0, #+0]
//   59    FTM0_SC   = 0x08 | FTM_SC_PS(1);     /* Edge Aligned PWM running from BUSCLK / 1 */
        LDR.N    R0,??DataTable7_6  ;; 0x40038000
        MOVS     R1,#+9
        STR      R1,[R0, #+0]
//   60    
//   61    buzzer_off();
        BL       buzzer_off
//   62 }
        POP      {R0,PC}          ;; return
//   63 
//   64 
//   65 /**   set_out_module
//   66  * \brief    updates FTM module and dutycycle
//   67  * \author   b01252
//   68  * \param    uint16 new_module
//   69  * \return   none
//   70  * \todo
//   71  * \warning
//   72  */ 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   73 void set_out_module(uint16 new_module)
//   74 {
//   75          FTM0_MOD = new_module;  //starts with E
set_out_module:
        LDR.N    R1,??DataTable7_3  ;; 0x40038008
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        STR      R0,[R1, #+0]
//   76          FTM0_C3V = new_module/2;
        UXTH     R0,R0            ;; ZeroExt  R0,R0,#+16,#+16
        MOVS     R1,#+2
        SDIV     R0,R0,R1
        LDR.N    R1,??DataTable7_5  ;; 0x40038028
        STR      R0,[R1, #+0]
//   77 }
        BX       LR               ;; return
//   78 
//   79 
//   80 /**   PIT_init
//   81  * \brief    Initialize Periodic interrupt timer,
//   82  * \brief    PIT1 is used for tone/buzzer time control
//   83  * \author   b01252
//   84  * \param    none
//   85  * \return   none
//   86  */  

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//   87 void PIT_init(void)
//   88 {
PIT_init:
        PUSH     {R7,LR}
//   89     SIM_SCGC6 |= SIM_SCGC6_PIT_MASK; // enable PIT module
        LDR.N    R0,??DataTable7_1  ;; 0x4004803c
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x800000
        LDR.N    R1,??DataTable7_1  ;; 0x4004803c
        STR      R0,[R1, #+0]
//   90     enable_irq(INT_PIT1 - 16);
        MOVS     R0,#+31
        BL       enable_irq
//   91        
//   92     PIT_MCR = 0x00;  // MDIS = 0  enables timer
        LDR.N    R0,??DataTable7_7  ;; 0x40037000
        MOVS     R1,#+0
        STR      R1,[R0, #+0]
//   93     PIT_TCTRL1 = 0x00; // disable PIT0
        LDR.N    R0,??DataTable7_8  ;; 0x40037118
        MOVS     R1,#+0
        STR      R1,[R0, #+0]
//   94     PIT_LDVAL1 = 72000; // 
        LDR.N    R0,??DataTable7_9  ;; 0x40037110
        LDR.N    R1,??DataTable7_10  ;; 0x11940
        STR      R1,[R0, #+0]
//   95     PIT_TCTRL1 = PIT_TCTRL_TIE_MASK; // enable PIT0 and interrupt
        LDR.N    R0,??DataTable7_8  ;; 0x40037118
        MOVS     R1,#+2
        STR      R1,[R0, #+0]
//   96     PIT_TFLG1 = 0x01; // clear flag
        LDR.N    R0,??DataTable7_11  ;; 0x4003711c
        MOVS     R1,#+1
        STR      R1,[R0, #+0]
//   97     PIT_TCTRL1 |= PIT_TCTRL_TEN_MASK;
        LDR.N    R0,??DataTable7_8  ;; 0x40037118
        LDR      R0,[R0, #+0]
        ORRS     R0,R0,#0x1
        LDR.N    R1,??DataTable7_8  ;; 0x40037118
        STR      R0,[R1, #+0]
//   98    
//   99 }
        POP      {R0,PC}          ;; return
//  100 
//  101 
//  102 
//  103 
//  104 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  105 void pit1_isrv(void)
//  106 {  
pit1_isrv:
        PUSH     {R7,LR}
//  107      static char count_mseg=125;
//  108     int32 i32temp;
//  109     PIT_TFLG1 = 0x01; // clear flag
        LDR.N    R0,??DataTable7_11  ;; 0x4003711c
        MOVS     R1,#+1
        STR      R1,[R0, #+0]
//  110     PIT_TCTRL1; // dummy read to ensure the interrupt, 
        LDR.N    R0,??DataTable7_8  ;; 0x40037118
        LDR      R0,[R0, #+0]
//  111                 // must be executed here, or interrupt will never happen.
//  112    
//  113     
//  114     if (count_mseg)count_mseg--;
        LDR.N    R1,??DataTable7_12
        LDRB     R1,[R1, #+0]
        CMP      R1,#+0
        BEQ.N    ??pit1_isrv_0
        LDR.N    R0,??DataTable7_12
        LDRB     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_12
        STRB     R0,[R1, #+0]
        B.N      ??pit1_isrv_1
//  115     else
//  116     {
//  117      count_mseg=125;
??pit1_isrv_0:
        LDR.N    R0,??DataTable7_12
        MOVS     R1,#+125
        STRB     R1,[R0, #+0]
//  118      base_time125m++; 
        LDR.N    R0,??DataTable7_13
        LDRB     R0,[R0, #+0]
        ADDS     R0,R0,#+1
        LDR.N    R1,??DataTable7_13
        STRB     R0,[R1, #+0]
//  119     }
//  120     if (ti_delay) ti_delay--;   
??pit1_isrv_1:
        LDR.N    R0,??DataTable7_14
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_2
        LDR.N    R0,??DataTable7_14
        LDR      R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_14
        STR      R0,[R1, #+0]
//  121     if (ti_accel_sampling) ti_accel_sampling--;
??pit1_isrv_2:
        LDR.N    R0,??DataTable7_15
        LDR      R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_3
        LDR.N    R0,??DataTable7_15
        LDR      R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_15
        STR      R0,[R1, #+0]
//  122     if (ti_tone_wait) ti_tone_wait--;
??pit1_isrv_3:
        LDR.N    R0,??DataTable7_16
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_4
        LDR.N    R0,??DataTable7_16
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_16
        STRH     R0,[R1, #+0]
//  123     if (ti_test_leds) ti_test_leds--;
??pit1_isrv_4:
        LDR.N    R0,??DataTable7_17
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_5
        LDR.N    R0,??DataTable7_17
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_17
        STRH     R0,[R1, #+0]
//  124     if (ti_test_adc) ti_test_adc--;
??pit1_isrv_5:
        LDR.N    R0,??DataTable7_18
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_6
        LDR.N    R0,??DataTable7_18
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_18
        STRH     R0,[R1, #+0]
//  125     
//  126     if (ti_echo) ti_echo--;
??pit1_isrv_6:
        LDR.N    R0,??DataTable7_19
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_7
        LDR.N    R0,??DataTable7_19
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_19
        STRH     R0,[R1, #+0]
//  127     /*tone service */
//  128     if (ti_tone)  ti_tone--;
??pit1_isrv_7:
        LDR.N    R0,??DataTable7_20
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_8
        LDR.N    R0,??DataTable7_20
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_20
        STRH     R0,[R1, #+0]
        B.N      ??pit1_isrv_9
//  129     else
//  130     {
//  131       if (tone_enable) buzzer_off();
??pit1_isrv_8:
        LDR.N    R0,??DataTable7_21
        LDRB     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_10
        BL       buzzer_off
//  132      tone_enable=0;
??pit1_isrv_10:
        LDR.N    R0,??DataTable7_21
        MOVS     R1,#+0
        STRB     R1,[R0, #+0]
//  133     }
//  134     
//  135     if (ti_fall) ti_fall--;
??pit1_isrv_9:
        LDR.N    R0,??DataTable7_22
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_11
        LDR.N    R0,??DataTable7_22
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_22
        STRH     R0,[R1, #+0]
//  136    /* 
//  137     if (ti_pause) ti_pause--;
//  138     else
//  139     {
//  140  
//  141     }
//  142     */
//  143     
//  144     if (ti_max_value) ti_max_value--;
??pit1_isrv_11:
        LDR.N    R0,??DataTable7_23
        LDRH     R0,[R0, #+0]
        CMP      R0,#+0
        BEQ.N    ??pit1_isrv_12
        LDR.N    R0,??DataTable7_23
        LDRH     R0,[R0, #+0]
        SUBS     R0,R0,#+1
        LDR.N    R1,??DataTable7_23
        STRH     R0,[R1, #+0]
        B.N      ??pit1_isrv_13
//  145     else
//  146     {
//  147       ti_max_value = 300;
??pit1_isrv_12:
        LDR.N    R0,??DataTable7_23
        MOV      R1,#+300
        STRH     R1,[R0, #+0]
//  148      //reduce clap enrgy in 1/8
//  149       if (clap_peak_energy>0) 
        LDR.N    R0,??DataTable7_24
        LDR      R0,[R0, #+0]
        CMP      R0,#+1
        BLT.N    ??pit1_isrv_13
//  150       {
//  151         i32temp =  clap_peak_energy - (clap_peak_energy<<3);
        LDR.N    R0,??DataTable7_24
        LDR      R0,[R0, #+0]
        LDR.N    R1,??DataTable7_24
        LDR      R1,[R1, #+0]
        SUBS     R0,R0,R1, LSL #+3
//  152         if (i32temp<0)i32temp=0;
        CMP      R0,#+0
        BPL.N    ??pit1_isrv_14
        MOVS     R0,#+0
//  153         clap_peak_energy =i32temp;
??pit1_isrv_14:
        LDR.N    R1,??DataTable7_24
        STR      R0,[R1, #+0]
//  154       }
//  155     }
//  156 }
??pit1_isrv_13:
        POP      {R0,PC}          ;; return

        SECTION `.data`:DATA:REORDER:NOROOT(0)
??count_mseg:
        DATA
        DC8 125
//  157 
//  158 
//  159 
//  160 
//  161 
//  162 /*PWM edge aligned high true pulses*/

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  163 void  buzzer_on(void)
//  164 {
//  165   FTM0_C3SC = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK;   //0x28;   /* No Interrupts; High True pulses on Edge Aligned PWM */
buzzer_on:
        LDR.N    R0,??DataTable7_4  ;; 0x40038024
        MOVS     R1,#+40
        STR      R1,[R0, #+0]
//  166 }
        BX       LR               ;; return
//  167 
//  168 
//  169 /*clear ouptut on compare */

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  170 void buzzer_off(void)
//  171 {
//  172 
//  173   FTM0_C3SC = FTM_CnSC_MSA_MASK | FTM_CnSC_ELSB_MASK;   //0x28;   /* No Interrupts; High True pulses on Edge Aligned PWM */
buzzer_off:
        LDR.N    R0,??DataTable7_4  ;; 0x40038024
        MOVS     R1,#+24
        STR      R1,[R0, #+0]
//  174 }
        BX       LR               ;; return
//  175 
//  176 
//  177 //to this scale ADD NOTE_C as initial note

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  178 void tone(TONES tone,uint16 time,uint16 pause)
//  179  {
tone:
        PUSH     {R3-R5,LR}
        MOVS     R4,R1
        MOVS     R5,R2
//  180    set_out_module(MONOCHROMATIC_SCALE[tone]);
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        LDR.N    R1,??DataTable7_25
        LDRH     R0,[R1, R0, LSL #+1]
        BL       set_out_module
//  181    ti_tone  = time  ;
        LDR.N    R0,??DataTable7_20
        STRH     R4,[R0, #+0]
//  182    ti_pause = time + pause;
        ADDS     R0,R5,R4
        LDR.N    R1,??DataTable7_26
        STRH     R0,[R1, #+0]
//  183    tone_enable=1;
        LDR.N    R0,??DataTable7_21
        MOVS     R1,#+1
        STRB     R1,[R0, #+0]
//  184    buzzer_on();
        BL       buzzer_on
//  185 
//  186  }
        POP      {R0,R4,R5,PC}    ;; return
//  187 
//  188 
//  189 

        SECTION `.text`:CODE:NOROOT(1)
        THUMB
//  190 void beep(uint8 tone,uint16 time)
//  191 {
beep:
        PUSH     {R4,LR}
        MOVS     R4,R1
//  192    set_out_module(MONOCHROMATIC_SCALE[tone]);
        UXTB     R0,R0            ;; ZeroExt  R0,R0,#+24,#+24
        LDR.N    R1,??DataTable7_25
        LDRH     R0,[R1, R0, LSL #+1]
        BL       set_out_module
//  193    ti_beep = time;
        LDR.N    R0,??DataTable7_27
        STRH     R4,[R0, #+0]
//  194    buzzer_on();
        BL       buzzer_on
//  195 }
        POP      {R4,PC}          ;; return

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7:
        DC32     0x40048038

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_1:
        DC32     0x4004803c

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_2:
        DC32     0x4004b010

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_3:
        DC32     0x40038008

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_4:
        DC32     0x40038024

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_5:
        DC32     0x40038028

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_6:
        DC32     0x40038000

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_7:
        DC32     0x40037000

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_8:
        DC32     0x40037118

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_9:
        DC32     0x40037110

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_10:
        DC32     0x11940

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_11:
        DC32     0x4003711c

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_12:
        DC32     ??count_mseg

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_13:
        DC32     base_time125m

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_14:
        DC32     ti_delay

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_15:
        DC32     ti_accel_sampling

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_16:
        DC32     ti_tone_wait

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_17:
        DC32     ti_test_leds

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_18:
        DC32     ti_test_adc

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_19:
        DC32     ti_echo

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_20:
        DC32     ti_tone

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_21:
        DC32     tone_enable

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_22:
        DC32     ti_fall

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_23:
        DC32     ti_max_value

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_24:
        DC32     clap_peak_energy

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_25:
        DC32     MONOCHROMATIC_SCALE

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_26:
        DC32     ti_pause

        SECTION `.text`:CODE:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
??DataTable7_27:
        DC32     ti_beep
//  196 
//  197 

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
//  198 const uint16 C_MAJ_SCALE[20]=
C_MAJ_SCALE:
        DATA
        DC16 47778, 42565, 37921, 35793, 31888, 28409, 25309, 23889, 21282
        DC16 18960, 17896, 15944, 14204, 12654, 11944, 10641, 9480, 8948, 7972
        DC16 7102
//  199 {
//  200     47778, // C off 0
//  201     42565, // D off 1
//  202     37921, // E off 2
//  203     35793, // F off 3
//  204     31888, // G off 4
//  205     28409, // A off 5
//  206     25309, // B off 6
//  207     23889, // C off 7
//  208     21282, // D off 8
//  209     18960, // E off 9
//  210     17896, // F off 10
//  211     15944, // G off 11
//  212     14204, // A off 12
//  213     12654, // B off 13
//  214     11944, // C off 14
//  215     10641, // D off 15
//  216     9480, // E off 16
//  217     8948, // F off 17
//  218     7972, // G off 18
//  219     7102, // A off 19
//  220 };
//  221 

        SECTION `.rodata`:CONST:REORDER:NOROOT(2)
//  222 const uint16 MONOCHROMATIC_SCALE[39]=
MONOCHROMATIC_SCALE:
        DATA
        DC16 63776, 60196, 56818, 53629, 50619, 47778, 45096, 42565, 40176
        DC16 37921, 35793, 33784, 31888, 30098, 28409, 26814, 25309, 23889
        DC16 22548, 21282, 20088, 18960, 17896, 16892, 15944, 15049, 14204
        DC16 13407, 12654, 11944, 11274, 10641, 10044, 9480, 8948, 8446, 7972
        DC16 7524, 7102
        DC8 0, 0

        SECTION `.iar_vfe_header`:DATA:REORDER:NOALLOC:NOROOT(2)
        SECTION_TYPE SHT_PROGBITS, 0
        DATA
        DC32 0

        SECTION __DLIB_PERTHREAD:DATA:REORDER:NOROOT(0)
        SECTION_TYPE SHT_PROGBITS, 0

        SECTION __DLIB_PERTHREAD_init:DATA:REORDER:NOROOT(0)
        SECTION_TYPE SHT_PROGBITS, 0

        END
//  223 {
//  224   63776, //G4 off = 0
//  225     60196, //G4_S off = 1
//  226     56818, //A4 off = 2
//  227     53629, //A4_S off = 3
//  228     50619, //B4 off = 4
//  229     47778, //C5 off = 5
//  230     45096, //C5_S off = 6
//  231     42565, //D5 off = 7
//  232     40176, //D5_S off = 8
//  233     37921, //E5 off = 9
//  234     35793, //F5 off = 10
//  235     33784, //F5_S off = 11
//  236     31888, //G5 off = 12
//  237     30098, //G5_S off = 13
//  238     28409, //A5 off = 14
//  239     26814, //A5_S off = 15
//  240     25309, //B5 off = 16
//  241     23889, //C6 off = 17
//  242     22548, //C6_S off = 18
//  243     21282, //D6 off = 19
//  244     20088, //D6_S off = 20
//  245     18960, //E6 off = 21
//  246     17896, //F6 off = 22
//  247     16892, //F6_S off = 23
//  248     15944, //G6 off = 24
//  249     15049, //G6_S off = 25
//  250     14204, //A6 off = 26
//  251     13407, //A6_S off = 27
//  252     12654, //B6 off = 28
//  253     11944, //C7 off = 29
//  254     11274, //C7_S off = 30
//  255     10641, //D7 off = 31
//  256     10044, //D7_S off = 32
//  257     9480, //E7 off = 33
//  258     8948, //F7 off = 34
//  259     8446, //F7_S off = 35
//  260     7972, //G7 off = 36
//  261     7524, //G7_S off = 37
//  262     7102 //A7 off = 38
//  263 
//  264 
//  265 };
//  266 
// 
//  31 bytes in section .bss
//   1 byte  in section .data
// 120 bytes in section .rodata
// 618 bytes in section .text
// 
// 618 bytes of CODE  memory
// 120 bytes of CONST memory
//  32 bytes of DATA  memory
//
//Errors: none
//Warnings: 1
