jarjonam 5 năm trước cách đây
commit
1bce86786d
65 tập tin đã thay đổi với 12512 bổ sung0 xóa
  1. 1276 0
      microcontroller/ADuC702x.lst
  2. BIN
      microcontroller/ADuC702x.o
  3. 412 0
      microcontroller/ADuC702x.s
  4. 516 0
      microcontroller/Demo - Copy.C
  5. 486 0
      microcontroller/Demo.C
  6. 439 0
      microcontroller/Demo1p2.C
  7. 1203 0
      microcontroller/Demo2016_05_13
  8. 445 0
      microcontroller/DemoHD.C
  9. 569 0
      microcontroller/DemoMem.C
  10. 390 0
      microcontroller/DemoPSD1p0.C
  11. 488 0
      microcontroller/Demo_original.C
  12. 410 0
      microcontroller/Demov1p0.C
  13. 43 0
      microcontroller/EOM_lock.Opt
  14. 102 0
      microcontroller/EOM_lock.Uv2
  15. BIN
      microcontroller/EOM_lock.axf
  16. 26 0
      microcontroller/EOM_lock.fed
  17. 605 0
      microcontroller/EOM_lock.hex
  18. 675 0
      microcontroller/EOM_lock.htm
  19. 4 0
      microcontroller/EOM_lock.lnp
  20. 982 0
      microcontroller/EOM_lock.map
  21. 645 0
      microcontroller/EOM_lock.plg
  22. 15 0
      microcontroller/EOM_lock.sct
  23. 21 0
      microcontroller/EOM_lock.tra
  24. 42 0
      microcontroller/EOM_lock_Opt.Bak
  25. 17 0
      microcontroller/EOM_lock_Target 1.dep
  26. 0 0
      microcontroller/EOM_lock_Uv2.Bak
  27. BIN
      microcontroller/demo.crf
  28. 14 0
      microcontroller/demo.d
  29. BIN
      microcontroller/demo.o
  30. 134 0
      microcontroller/demo2016_06_05
  31. 156 0
      microcontroller/i2c_first
  32. 65 0
      microcontroller/irq_arm.c
  33. BIN
      microcontroller/irq_arm.crf
  34. 1 0
      microcontroller/irq_arm.d
  35. BIN
      microcontroller/irq_arm.o
  36. 436 0
      pi/ADUCv2p1.py
  37. 14 0
      pi/Vout_carac.py
  38. BIN
      pi/__pycache__/ADUCv2p1.cpython-35.pyc
  39. 46 0
      pi/accuracy_vs_noise.py
  40. 2 0
      pi/data/long_term.csv
  41. 1 0
      pi/data/waveforms/233.csv
  42. BIN
      pi/drift.npy
  43. BIN
      pi/drift2.npy
  44. BIN
      pi/drift3.npy
  45. 79 0
      pi/fit_gain.py
  46. 40 0
      pi/long_term_drift.py
  47. 12 0
      pi/long_term_drift_analysis.py
  48. 155 0
      pi/oscillo_charac2.py
  49. 13 0
      pi/read_scan.py
  50. 41 0
      pi/scan.py
  51. 59 0
      pi/scan_analysis.py
  52. BIN
      pi/scan_data.npy
  53. BIN
      pi/scan_data_ag.npy
  54. BIN
      pi/scan_data_ag2.npy
  55. BIN
      pi/scan_data_new_R.npy
  56. BIN
      pi/scan_data_new_R_HR.npy
  57. 40 0
      pi/scan_gain_in.py
  58. 414 0
      pi/server.py
  59. BIN
      pi/tmp.npy
  60. 81 0
      pi/web/main.css
  61. 132 0
      pi/web/main.html
  62. 332 0
      pi/web/main.js
  63. 7 0
      pi/web/plotly-latest.min.js
  64. 78 0
      pi/web/toastify.css
  65. 349 0
      pi/web/toastify.js

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1276 - 0
microcontroller/ADuC702x.lst


BIN
microcontroller/ADuC702x.o


+ 412 - 0
microcontroller/ADuC702x.s

@@ -0,0 +1,412 @@
+;/*****************************************************************************/
+;/* STARTUP.S: Startup file for ADI ADuC702x device series                    */
+;/*****************************************************************************/
+;/* <<< Use Configuration Wizard in Context Menu >>>                          */ 
+;/*****************************************************************************/
+;/* This file is part of the uVision/ARM development tools.                   */
+;/* Copyright (c) 2005-2006 Keil Software. All rights reserved.               */
+;/* This software may only be used under the terms of a valid, current,       */
+;/* end user licence from KEIL for a compatible version of KEIL software      */
+;/* development tools. Nothing else gives you the right to use this software. */
+;/*****************************************************************************/
+
+
+;/*
+; *  The STARTUP.S code is executed after CPU Reset. This file may be 
+; *  translated with the following SET symbols. In uVision these SET 
+; *  symbols are entered under Options - ASM - Define.
+; *
+; *  RAM_INTVEC: when set the startup code copies exception vectors 
+; *  from on-chip Flash to on-chip RAM and remaps RAM to address 0.
+; */
+
+
+; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
+
+Mode_USR        EQU     0x10
+Mode_FIQ        EQU     0x11
+Mode_IRQ        EQU     0x12
+Mode_SVC        EQU     0x13
+Mode_ABT        EQU     0x17
+Mode_UND        EQU     0x1B
+Mode_SYS        EQU     0x1F
+
+I_Bit           EQU     0x80            ; when I bit is set, IRQ is disabled
+F_Bit           EQU     0x40            ; when F bit is set, FIQ is disabled
+
+
+;// <h> Stack Configuration (Stack Sizes in Bytes)
+;//   <o0> Undefined Mode      <0x0-0xFFFFFFFF:8>
+;//   <o1> Supervisor Mode     <0x0-0xFFFFFFFF:8>
+;//   <o2> Abort Mode          <0x0-0xFFFFFFFF:8>
+;//   <o3> Fast Interrupt Mode <0x0-0xFFFFFFFF:8>
+;//   <o4> Interrupt Mode      <0x0-0xFFFFFFFF:8>
+;//   <o5> User/System Mode    <0x0-0xFFFFFFFF:8>
+;// </h>
+
+UND_Stack_Size  EQU     0x00000080
+SVC_Stack_Size  EQU     0x00000080
+ABT_Stack_Size  EQU     0x00000080
+FIQ_Stack_Size  EQU     0x00000080
+IRQ_Stack_Size  EQU     0x00000080
+USR_Stack_Size  EQU     0x00000400
+
+Stack_Size      EQU     (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
+                         FIQ_Stack_Size + IRQ_Stack_Size + USR_Stack_Size)
+
+                AREA    STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem       SPACE   Stack_Size
+
+Stack_Top       EQU     Stack_Mem + Stack_Size
+
+
+;// <h> Heap Configuration
+;//   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF>
+;// </h>
+
+Heap_Size       EQU     0x00000000
+
+                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
+Heap_Mem        SPACE   Heap_Size
+
+
+; MMR definitions
+MMR_BASE        EQU     0xFFFF0000      ; MMR Base Address
+REMAP_OFFSET    EQU         0x0220
+POWKEY1_OFFSET  EQU         0x0404
+POWCON_OFFSET   EQU         0x0408
+POWKEY2_OFFSET  EQU         0x040C
+
+;// <e> PLL Setup
+;//   <o1.0..2>  CD: PLL Multiplier Selection
+;//               <0-7>
+;//               <i> CD Value
+;//   <o1.3>     FINT: Fast Interrupt
+;//               <0-1>
+;//               <i> Switches to CD0 for FIQ
+;// </e>
+PLL_SETUP       EQU     1
+PLLCFG_Val      EQU     0x00000001
+
+
+;// <e> Pin Setup
+GPIO_SETUP      EQU     0
+GPIOBASE        EQU     0xFFFFF400
+
+;//   <h>  Port 0
+;//     <o.0..1>    P0.0  <0=> GPIO      <1=> CMPOUT    <2=> MS2     <3=> PLAI[7]
+;//     <o.4..5>    P0.1  <0=> GPIO      <1=> ---       <2=> XBEN0   <3=> ---
+;//     <o.8..9>    P0.2  <0=> GPIO      <1=> ---       <2=> XBEN1   <3=> ---
+;//     <o.12..13>  P0.3  <0=> GPIO      <1=> TRST      <2=> XA16    <3=> ADCBUSY
+;//     <o.16..17>  P0.4  <0=> GPIO/IRQ0 <1=> CONVSTART <2=> MS1     <3=> PLAO[1]
+;//     <o.20..21>  P0.5  <0=> GPIO/IRQ1 <1=> ADCBUSY   <2=> MS0     <3=> PLAO[2]
+;//     <o.24..25>  P0.6  <0=> GPIO      <1=> MRST      <2=> XAE     <3=> PLAO[3]
+;//     <o.28..29>  P0.7  <0=> GPIO      <1=> ECLK      <2=> SIN     <3=> PLAO[4]
+;//   </h>
+GP0CON_Val      EQU     0x00000000
+
+;//   <h>  Port 1
+;//     <o.0..1>    P1.0  <0=> GPIO      <1=> SIN       <2=> I2C0SCL <3=> PLAI[0]
+;//     <o.4..5>    P1.1  <0=> GPIO      <1=> SOUT      <2=> I2C0SDA <3=> PLAI[1]
+;//     <o.8..9>    P1.2  <0=> GPIO      <1=> RTS       <2=> I2C1SCL <3=> PLAI[2]
+;//     <o.12..13>  P1.3  <0=> GPIO      <1=> CTS       <2=> I2C1SDA <3=> PLAI[3]
+;//     <o.16..17>  P1.4  <0=> GPIO/IRQ2 <1=> RI        <2=> SPICLK  <3=> PLAI[4]
+;//     <o.20..21>  P1.5  <0=> GPIO/IRQ3 <1=> DCD       <2=> SPIMISO <3=> PLAI[5]
+;//     <o.24..25>  P1.6  <0=> GPIO      <1=> DSR       <2=> SPIMOSI <3=> PLAI[6]
+;//     <o.28..29>  P1.7  <0=> GPIO      <1=> DTR       <2=> SPICSL  <3=> PLAO[0]
+;//   </h>
+GP1CON_Val      EQU     0x00000000
+
+;//   <h>  Port 2
+;//     <o.0..1>    P2.0  <0=> GPIO      <1=> CONVSTART <2=> SOUT    <3=> PLAO[5]
+;//     <o.4..5>    P2.1  <0=> GPIO      <1=> ---       <2=> XWS     <3=> PLAO[6]
+;//     <o.8..9>    P2.2  <0=> GPIO      <1=> ---       <2=> XRS     <3=> PLAO[7]
+;//     <o.12..13>  P2.3  <0=> GPIO      <1=> ---       <2=> XAE     <3=> ---
+;//     <o.16..17>  P2.4  <0=> GPIO      <1=> ---       <2=> MS0     <3=> ---
+;//     <o.20..21>  P2.5  <0=> GPIO      <1=> ---       <2=> MS1     <3=> ---
+;//     <o.24..25>  P2.6  <0=> GPIO      <1=> ---       <2=> MS2     <3=> ---
+;//     <o.28..29>  P2.7  <0=> GPIO      <1=> ---       <2=> MS3     <3=> ---
+;//   </h>
+GP2CON_Val      EQU     0x00000000
+
+;//   <h>  Port 3
+;//     <o.0..1>    P3.0  <0=> GPIO      <1=> PWM0H     <2=> XAD0    <3=> PLAI[8]
+;//     <o.4..5>    P3.1  <0=> GPIO      <1=> PWM0L     <2=> XAD1    <3=> PLAI[9]
+;//     <o.8..9>    P3.2  <0=> GPIO      <1=> PWM1H     <2=> XAD2    <3=> PLAI[10]
+;//     <o.12..13>  P3.3  <0=> GPIO      <1=> PWM1L     <2=> XAD3    <3=> PLAI[11]
+;//     <o.16..17>  P3.4  <0=> GPIO      <1=> PWM2H     <2=> XAD4    <3=> PLAI[12]
+;//     <o.20..21>  P3.5  <0=> GPIO      <1=> PWM2L     <2=> XAD5    <3=> PLAI[13]
+;//     <o.24..25>  P3.6  <0=> GPIO      <1=> PWMTRIP   <2=> XAD6    <3=> PLAI[14]
+;//     <o.28..29>  P3.7  <0=> GPIO      <1=> PWMSYNC   <2=> XAD7    <3=> PLAI[15]
+;//   </h>
+GP3CON_Val      EQU     0x00000000
+
+;//   <h>  Port 4
+;//     <o.0..1>    P4.0  <0=> GPIO      <1=> ---       <2=> XAD8    <3=> PLAO[8]
+;//     <o.4..5>    P4.1  <0=> GPIO      <1=> ---       <2=> XAD9    <3=> PLAO[9]
+;//     <o.8..9>    P4.2  <0=> GPIO      <1=> ---       <2=> XAD10   <3=> PLAO[10]
+;//     <o.12..13>  P4.3  <0=> GPIO      <1=> ---       <2=> XAD11   <3=> PLAO[11]
+;//     <o.16..17>  P4.4  <0=> GPIO      <1=> ---       <2=> XAD12   <3=> PLAO[12]
+;//     <o.20..21>  P4.5  <0=> GPIO      <1=> ---       <2=> XAD13   <3=> PLAO[13]
+;//     <o.24..25>  P4.6  <0=> GPIO      <1=> ---       <2=> XAD14   <3=> PLAO[14]
+;//     <o.28..29>  P4.7  <0=> GPIO      <1=> ---       <2=> XAD15   <3=> PLAO[15]
+;//   </h>
+GP4CON_Val      EQU     0x00000000
+
+;// </e>
+
+
+;// <e> External Memory Interface
+XM_SETUP        EQU     0
+XMBASE          EQU     0xFFFFF000
+
+;//   <e.0>  Enable Memory Region 0
+;//     <o.1>       Data Bus Width  <0=> 8-bit  <1=> 16-bit
+;//     <o1.11>     Enable Dynamic Addressing
+;//     <o1.15>     Byte Enabled Write Strobe
+;//     <o1.10>     Disable extra Address Latch Hold Cycle
+;//     <o1.8>      Disable extra Write Address Hold Cycle
+;//     <o1.9>      Disable Read Bus Turn Cycle
+;//     <o1.12..14> Address Wait States <0-7>
+;//                 <i> Number of Wait States added for AE
+;//     <o1.0..3>   Read Wait States <0-15>
+;//                 <i> Number of Wait States added for RS
+;//     <o1.4..7>   Write Wait States <0-15>
+;//                 <i> Number of Wait States added for WS
+;//   </e>
+XM0CON_Val      EQU     0x00000000
+XM0PAR_Val      EQU     0x000070FF
+
+;//   <e.0>  Enable Memory Region 1
+;//     <o.1>       Data Bus Width  <0=> 8-bit  <1=> 16-bit
+;//     <o1.11>     Enable Dynamic Addressing
+;//     <o1.15>     Byte Enabled Write Strobe
+;//     <o1.10>     Disable extra Address Latch Hold Cycle
+;//     <o1.8>      Disable extra Write Address Hold Cycle
+;//     <o1.9>      Disable Read Bus Turn Cycle
+;//     <o1.12..14> Address Wait States <0-7>
+;//                 <i> Number of Wait States added for AE
+;//     <o1.0..3>   Read Wait States <0-15>
+;//                 <i> Number of Wait States added for RS
+;//     <o1.4..7>   Write Wait States <0-15>
+;//                 <i> Number of Wait States added for WS
+;//   </e>
+XM1CON_Val      EQU     0x00000000
+XM1PAR_Val      EQU     0x000070FF
+
+;//   <e.0>  Enable Memory Region 2
+;//     <o.1>       Data Bus Width  <0=> 8-bit  <1=> 16-bit
+;//     <o1.11>     Enable Dynamic Addressing
+;//     <o1.15>     Byte Enabled Write Strobe
+;//     <o1.10>     Disable extra Address Latch Hold Cycle
+;//     <o1.8>      Disable extra Write Address Hold Cycle
+;//     <o1.9>      Disable Read Bus Turn Cycle
+;//     <o1.12..14> Address Wait States <0-7>
+;//                 <i> Number of Wait States added for AE
+;//     <o1.0..3>   Read Wait States <0-15>
+;//                 <i> Number of Wait States added for RS
+;//     <o1.4..7>   Write Wait States <0-15>
+;//                 <i> Number of Wait States added for WS
+;//   </e>
+XM2CON_Val      EQU     0x00000000
+XM2PAR_Val      EQU     0x000070FF
+
+;//   <e.0>  Enable Memory Region 3
+;//     <o.1>       Data Bus Width  <0=> 8-bit  <1=> 16-bit
+;//     <o1.11>     Enable Dynamic Addressing
+;//     <o1.15>     Byte Enabled Write Strobe
+;//     <o1.10>     Disable extra Address Latch Hold Cycle
+;//     <o1.8>      Disable extra Write Address Hold Cycle
+;//     <o1.9>      Disable Read Bus Turn Cycle
+;//     <o1.12..14> Address Wait States <0-7>
+;//                 <i> Number of Wait States added for AE
+;//     <o1.0..3>   Read Wait States <0-15>
+;//                 <i> Number of Wait States added for RS
+;//     <o1.4..7>   Write Wait States <0-15>
+;//                 <i> Number of Wait States added for WS
+;//   </e>
+XM3CON_Val      EQU     0x00000000
+XM3PAR_Val      EQU     0x000070FF
+
+;//   <e.0>         Memory Muxed Mode
+XMCFG_Val       EQU     0x00000001
+;//   </e>
+
+;// </e>
+
+
+                PRESERVE8
+                
+
+; Area Definition and Entry Point
+;  Startup Code must be linked first at Address at which it expects to run.
+
+                AREA    Reset, CODE, READONLY
+                ARM
+
+
+; Exception Vectors
+;  Mapped to Address 0.
+;  Absolute addressing mode must be used.
+;  Dummy Handlers are implemented as infinite loops which can be modified.
+
+Vectors         LDR     PC, Reset_Addr         
+                LDR     PC, Undef_Addr
+                LDR     PC, SWI_Addr
+                LDR     PC, PAbt_Addr
+                LDR     PC, DAbt_Addr
+                DCD     0xFFFFFFFF                       ; Reserved Vector 
+                LDR     PC, IRQ_Addr
+                LDR     PC, FIQ_Addr
+
+                EXTERN Undef_Handler
+                EXTERN SWI_Handler
+                EXTERN PAbt_Handler
+                EXTERN DAbt_Handler
+                EXTERN IRQ_Handler
+                EXTERN FIQ_Handler
+
+Reset_Addr      DCD     Reset_Handler
+Undef_Addr      DCD     Undef_Handler
+SWI_Addr        DCD     SWI_Handler
+PAbt_Addr       DCD     PAbt_Handler
+DAbt_Addr       DCD     DAbt_Handler
+                DCD     0xFFFFFFFF                       ; Reserved Address 
+IRQ_Addr        DCD     IRQ_Handler
+FIQ_Addr        DCD     FIQ_Handler
+
+
+; Reset Handler
+
+                EXPORT  Reset_Handler
+Reset_Handler   
+
+
+; Setup PLL
+                IF      PLL_SETUP <> 0
+                LDR     R0, =MMR_BASE
+                MOV     R1, #0x01         
+                STR     R1, [R0,#POWKEY1_OFFSET]          
+                MOV     R1, #PLLCFG_Val      
+                STR     R1, [R0,#POWCON_OFFSET]    
+                MOV     R1, #0xF4
+                STR     R1, [R0,#POWKEY2_OFFSET]
+                ENDIF   ; PLL_SETUP
+
+
+; Setup Pins
+                IF      GPIO_SETUP <> 0
+
+                ADR     R10, GPIO_CFG          ; Pointer to GPIO CFG
+                LDMIA   R10, {R0-R5}           ; Load GPIO Configuration
+                STMIA   R0, {R1-R5}            ; Store GPxCON
+                B       GPIO_END
+
+GPIO_CFG        DCD     GPIOBASE
+                DCD     GP0CON_Val
+                DCD     GP1CON_Val
+                DCD     GP2CON_Val
+                DCD     GP3CON_Val
+                DCD     GP4CON_Val
+GPIO_END 
+
+                ENDIF   ; GPIO_SETUP
+
+
+; Setup External Memory Interface
+                IF      XM_SETUP <> 0
+
+                ADR     R10, XM_CFG            ; Pointer to XM CFG
+                LDMIA   R10, {R0-R9}           ; Load XM Configuration
+                STR     R1, [R0],#0x10         ; Store XMCFG
+                STMIA   R0, {R2-R9}            ; Store XMxCON & XMxPAR
+                B       XM_END
+
+XM_CFG          DCD     XMBASE
+                DCD     XMCFG_Val
+                DCD     XM0CON_Val
+                DCD     XM1CON_Val
+                DCD     XM2CON_Val
+                DCD     XM3CON_Val
+                DCD     XM0PAR_Val
+                DCD     XM1PAR_Val
+                DCD     XM2PAR_Val
+                DCD     XM3PAR_Val
+XM_END
+
+                ENDIF   ; XM_SETUP
+
+
+; Copy Exception Vectors to Internal RAM and Remap Memory
+;  (when Interrupt Vectors are in RAM)
+									   
+                IF      :DEF:RAM_INTVEC
+                ADR     R8, Vectors         ; Source
+                LDR     R9, =0x00010000     ; Destination
+                LDMIA   R8!, {R0-R7}        ; Load Vectors 
+                STMIA   R9!, {R0-R7}        ; Store Vectors 
+                LDMIA   R8!, {R0-R7}        ; Load Handler Addresses 
+                STMIA   R9!, {R0-R7}        ; Store Handler Addresses 
+                LDR     R0, =MMR_BASE
+                MOV     R1, #1     
+                STR     R1, [R0,#REMAP_OFFSET]          
+                ENDIF
+
+
+; Setup Stack for each mode
+
+                LDR     R0, =Stack_Top
+
+;  Enter Undefined Instruction Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit
+                MOV     SP, R0
+                SUB     R0, R0, #UND_Stack_Size
+
+;  Enter Abort Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit
+                MOV     SP, R0
+                SUB     R0, R0, #ABT_Stack_Size
+
+;  Enter FIQ Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit
+                MOV     SP, R0
+                SUB     R0, R0, #FIQ_Stack_Size
+
+;  Enter IRQ Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
+                MOV     SP, R0
+                SUB     R0, R0, #IRQ_Stack_Size
+
+;  Enter Supervisor Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit
+                MOV     SP, R0
+                SUB     R0, R0, #SVC_Stack_Size
+
+;  Enter User Mode and set its Stack Pointer
+                MSR     CPSR_c, #Mode_USR
+                MOV     SP, R0
+                SUB     SL, SP, #USR_Stack_Size
+
+
+; Enter the C code
+
+                IMPORT  __main
+                LDR     R0, =__main
+                BX      R0
+
+
+; User Initial Stack & Heap
+                AREA    |.text|, CODE, READONLY
+
+                IMPORT  __use_two_region_memory
+                EXPORT  __user_initial_stackheap
+__user_initial_stackheap
+
+                LDR     R0, =  Heap_Mem
+                LDR     R1, =(Stack_Mem + USR_Stack_Size)
+                LDR     R2, = (Heap_Mem +      Heap_Size)
+                LDR     R3, = Stack_Mem
+                BX      LR
+
+
+                END

+ 516 - 0
microcontroller/Demo - Copy.C

@@ -0,0 +1,516 @@
+/*
+
+    v2.0
+
+
+	this program use old code used in another experiment
+
+    "int" is used for the ADC and DAC data although it should be unsigned,
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short Vlearn;
+
+double Vin,Vin_gnd;
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned char transf,enab_gnd,busy,remote_trigg;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+float Gain;
+
+
+unsigned char pga_state = 0x08; // gain 1 channel 8
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+
+void set_pga(){
+
+	SPITX = 0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	SPITX = pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+
+}
+
+
+void get_pga(){
+
+	SPITX = 0x7A;//0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	SPITX = 0;//pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	delay(500);
+
+	SPITX = 0;//0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	SPITX = 0;//pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+}
+
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N;
+	double sum,sum_gnd;
+	unsigned short Vout1, Vout2;
+
+	//double Vin,Vin_gnd;
+	//int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger :
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	short valid_data;
+	int k;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+	// locking parameters initialization
+//	cnt = 0;      //
+	N = 10;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vin_gnd = 0;
+//	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 200;
+	Vset = 200;
+	Vlearn = 2000;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+
+	GP1CON = 0x22220022;				// configure SPI such the P1.0 and P1.1 are set for I2C0
+										// P1.2 and P1.3 are set for GPIO (connected on 50Ohms driver TTL)
+										// P1.4-7 on SPI
+	SPIDIV = 0xCC;						// set SPI clock 40960000/(2x(1+SPIDIV))
+										// 0xCC = 100kHz
+										//
+	SPICON = 0x1043;					// enable SPI master in continuous transfer mode
+										// slave select will stay low during the all transmission
+
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+
+	I2C0CFG = 0x04001;
+	// Slave ID
+	I2C0ID0 = (0x50)<<1;//(0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v2.0 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+
+	plist[110] = (unsigned char*)&Vlearn;
+	plist[111] = (unsigned char*)&Vin;
+	plist[112] = (unsigned char*)&Vin_gnd;
+	plist[113] = (unsigned char*)&wf_cnt;
+	plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	plist[136] = (unsigned char*)&pga_state;
+
+
+
+
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	wf_cnt = 0;
+	v_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+	remote_trigg = 0;
+	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+		Write_Digital(0, 0);
+
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+
+			armed = 0;
+			//busy = 0;
+			//*** aquisition of the waveform  ***
+			/*for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				tmp_dat[k]= ADCDAT; // read voltage from ADC0
+			}
+			for(k=0;k<wf_len;k++){
+				Data[k]= (tmp_dat[k]&0xFFF0000)>>16; // read voltage from ADC0
+
+			}*/
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+			}
+
+			trigg_cnt++;
+
+			if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+				//*** copy for the i2c ***
+				memcpy(BigDat,Data,256*sizeof(short));
+				wf_cnt++;
+
+				cnt_N++;
+
+				//sum of the data
+				for(k=start;k<stop;k++){
+					sum += Data[k];
+					//cnt++;
+				}
+				for(k=start_gnd;k<stop_gnd;k++){
+					sum_gnd += Data[k];
+					//cnt_gnd++;
+				}
+				if(cnt_N>=N){
+					Vin = sum/(cnt_N*(stop-start));	// calculate average value
+					Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+					valid_data = 1;
+					v_cnt++;
+					sum = 0; // initialization	of the measurement
+					sum_gnd = 0;
+					cnt_N = 0;
+				}
+			}
+			else busy = 0;
+
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			Write_Digital(0, 1);
+			// LOCK MODE
+			if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(valid_data==1){
+					valid_data=0;
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+
+					// Adjust Vout1 if necessary
+					if (Vout2 < 2000 || Vout2 > 4000){
+                        Vout1 = Vout1 + (Vout2-3000)/20;
+                        Vout2 = 3000;
+					}
+
+					if(Vout1>4095){
+						//Write_Digital(0,1);	 
+						Vout1 = 4095;
+					}
+					else if(Vout1<1){
+                        //Write_Digital(0,1);
+						Vout1 = 1;
+					}else{
+						//Write_Digital(0,0);
+					}
+
+					/*if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}*/
+				}
+			}
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			else{
+				if(valid_data==1){
+					valid_data=0;
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout1 = Vlearn;
+				Vout2 = Vlearn;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC1DAT = DATtoADC(Vout1); // output voltage
+			//DAC2DAT = DATtoADC(Vout2); // output voltage
+			
+		}
+
+	}
+}
+
+
+
+
+int main(void)
+{
+
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+				if(Byte_addr==137)
+					set_pga();
+				if(Byte_addr==138)
+					get_pga();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];
+
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;
+			}
+	}
+
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();
+	}
+
+	else if((status & 0x0400)==0x0400)   //
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+
+	busy=1;
+}

+ 486 - 0
microcontroller/Demo.C

@@ -0,0 +1,486 @@
+/*
+	v3.0
+
+	New board.
+	- Less input noise
+	- High range, high precision output voltage by using 2 DACS
+	- Automatic gain and offset selection
+	- Faster loop (<100microseconds after waveform acquisition is completed)
+*/
+
+#include<ADuC7020.h>
+
+#include<stdlib.h>
+
+#include<stdio.h>
+
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+///////////////////////////////////////
+// VARIABLE AND OPTION DEFINITIONS
+///////////////////////////////////////
+
+short i = 0; // Dummy loop variables
+// I2C stuff
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+// BigDat stores the latest valid waveform
+// This is used so that if the acquisition is corrupted due to communication
+// with the board only data but not BigDat is corrupted
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+// DAC outputs
+unsigned short Vout[4]; // DAC values, used via get_DACs and set_DACs
+unsigned short Vlearn; // Coarse output of the board when in learn mode
+
+double Vin, Vin_gnd; // Measurements of the signal and ground in the last waveform
+
+unsigned short start, stop; // Points at which to start and stop measuring the signal
+unsigned short start_gnd, stop_gnd; // Points at which to start and stop measuring the background
+unsigned short Vset; // Value measured in learn mode to which we aim to stabilize in lock mode
+unsigned short wf_len; // Number of points to measure
+unsigned short step_max; // Maximum fine output step allowed in one iteration of the loop
+unsigned short N; // Number of waveforms to average before stabilizing
+
+unsigned char transf; // i2c
+unsigned short enab_gnd; // Subtract the background from the signal in enab_gnd=1. 
+unsigned short busy; // i2c
+unsigned short remote_trigg; // Set to 0 so that the microcontroller uses the trigger input, 
+// set it to 1 so that it continuously triggers
+unsigned short auto_set_pga; // Whether the microcontroller should automatically select the 
+// best offset and gain when in learn mode
+unsigned short coarse_fine_ratio; // Ratio of sensitivities of the fine to coarse voltage 
+// outputs of the board
+unsigned short mode; // read_only; 0 when in learn; 1 when in lock
+unsigned short out_of_lock; // 1 when the board is out of lock
+
+unsigned int trigg_cnt; // Total number of triggers. Never reset, may overflow.
+unsigned long long int v_cnt; // Total number of Vout updates. Never reset, may overflow.
+unsigned long long int wf_cnt; // Total number of non-corrupted waveforms measured so far. May overflow.
+
+float Gain; // Gain of the feedback loop
+
+
+// pga_state is defined via = g*16+8 where g is such that the gain G
+// in the input measurements is G=2^g and G is one of {1, 2, 4, 8, 16, 32, 64, 128}
+// i.e. 0<g<7 or pga_state = {0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78}
+unsigned char pga_state = 0x08; // gain 1 channel 8 default
+
+unsigned char * pbuff; // Pi communication
+unsigned char * plist[256];
+
+///////////////////////////////////////
+// HELPER FUNCTIONS
+///////////////////////////////////////
+
+// Dummy delay function
+void delay(int length) {
+  while (length >= 0)
+    length--;
+}
+
+// Conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC) {
+  return (ADC & 0xFFF0000) >> 16;
+}
+// Conversion of 12bits integer into the corresponding ADC or DAC value
+unsigned long DATtoADC(int DAT) {
+  unsigned long ADC;
+  ADC = DAT;
+  return ADC << 16;
+}
+unsigned long DATtoDAC(unsigned short DAT) {
+  unsigned int ADC;
+  ADC = DAT;
+  return ADC << 16;
+}
+
+// Read GPIO pin P0.n. Return is either 0 (low) or (high)
+int Read_Digital(int n) {
+  return ((GP0DAT & 0x000000FF) >> n) & 0x1;
+}
+// Write to GPIO pin P2.n. State is either 0 (low) or (high)
+void Write_Digital(int n, int state) {
+  if (state == 1)
+    GP2DAT = (0x00000001 << (n + 16)) | GP2DAT;
+  else
+    GP2DAT = ~((0x00000001 << (n + 16)) | (~GP2DAT));
+}
+
+// TO DO
+void ADCpoweron(int time) {
+  ADCCON = 0x620; // power-on the ADC
+  while (time >= 0) // wait for ADC to be fully powered on
+    time--;
+}
+
+// Sync the values of the DACs with those stored in the array Vout
+// i.e. after changing the value in Vout[i] remember to call this
+void set_DACs(void) {
+  DAC0DAT = DATtoDAC(Vout[0]);
+  DAC1DAT = DATtoDAC(Vout[1]);
+  DAC2DAT = DATtoDAC(Vout[2]);
+  DAC3DAT = DATtoDAC(Vout[3]);
+}
+void get_DACs(void) {
+  Vout[0] = DAC0DAT >> 16;
+  Vout[1] = DAC1DAT >> 16;
+  Vout[2] = DAC2DAT >> 16;
+  Vout[3] = DAC3DAT >> 16;
+}
+
+// Sync the state of the pga with that stored in the pga_state
+// i.e. after changing the value of pga_state remember to call this
+void set_pga() {
+  SPITX = 0x3A; // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+  SPITX = pga_state; // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+}
+void get_pga() {
+  SPITX = 0x7A; //0x3A;				  // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+  SPITX = 0; //pga_state;				  // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+  delay(500);
+  SPITX = 0; //0x3A;				  // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+  SPITX = 0; //pga_state;				  // transmit command or any dummy data
+  while ((SPISTA & 0x02) != 0x02); // wait for data received status bit
+
+}
+
+///////////////////////////////////////
+// MAIN FUNCTION: LOCKING
+///////////////////////////////////////
+
+void lock_StabPulse_i2c(void) {
+  // DEFINITIONS AND INITIALIZATION //////////////////////
+  unsigned int cnt_N; // Number of non-corrupted waveforms measured
+  unsigned long int sum, sum_gnd; // Sum of the points in the signal and background
+  unsigned short Vout0, Vout1, Vout2; // Used to set the DACs
+  // Vout0: input offset; Vout1: coarse output; Vout2: fine output
+
+  int step = 100; // Step to move by in the loop, dummy initialization
+  short armed; // This is used to detect the trigger :
+  // when the trigger input is low armed is set to 1
+  // when a measurement start it is set to 0
+  short valid_data; // 
+  register int k; // Dummy loop variable
+  unsigned short Data[256]; // Waveform measurement
+
+  // 
+  POWKEY1 = 0x01;
+  POWCON = 0x00; // 41.78MHz
+  POWKEY2 = 0xF4;
+
+  // ADC&DAC setting
+  ADCpoweron(20000); // power on ADC
+  REFCON = 0x01; // internal 2.5V reference
+  DAC0CON = 0x12; // AGND-ARef range 0x12 2.5V
+  DAC1CON = 0x12; // AGND-ARef range 0x12 2.5V
+  DAC2CON = 0x12; // AGND-ARef range 0x12 2.5V
+  DAC3CON = 0x12; // AGND-ARef range 0x12 2.5V
+  ADCCP = 0x03; // conversion on ADC0
+  ADCCON = 0x3E4; // continuous conversion
+
+  // IO setting
+  GP2CON = 0x00000000; // IO initialization
+  GP2DAT = 0xFF000000; // set P2.n as digital output
+  GP0CON = 0x00000000; // IO initialization
+  GP0DAT = 0x00000000; // set P0.n as digital input
+
+  // Initialize locking parameter defaults
+  // This will likely be selected using the Pi
+  N = 10;
+  Vin = 0;
+  Vin_gnd = 0;
+  start = 100;
+  stop = 200;
+  start_gnd = 0;
+  stop_gnd = 100;
+  wf_len = 200;
+  Vset = 0;
+  Vlearn = 2000;
+  step = 50;
+  step_max = 100;
+  Gain = 1;
+
+  transf = 0;
+  trigg_cnt = 0;
+  wf_cnt = 0;
+  v_cnt = 0;
+  cnt_N = 0;
+  enab_gnd = 0;
+  remote_trigg = 0;
+  auto_set_pga = 0;
+  mode = 0; //read only
+  out_of_lock = 0;
+  coarse_fine_ratio = 20; //As per circuit design; can be tuned by Pi
+  valid_data = 0;
+
+  // SPI configuration
+  GP1CON = 0x22220022; // configure SPI such the P1.0 and P1.1 are set for I2C0
+  // P1.2 and P1.3 are set for GPIO (connected on 50Ohms driver TTL)
+  // P1.4-7 on SPI
+  SPIDIV = 0xCC; // set SPI clock 40960000/(2x(1+SPIDIV))
+  // 0xCC = 100kHz
+  SPICON = 0x1043; // enable SPI master in continuous transfer mode
+  // slave select will stay low during the all transmission
+
+  IRQ = My_IRQ_Handler;
+  IRQEN = 0x200; // I2C0 Slave Interupt
+
+  I2C0CFG = 0x04001;
+  // Slave ID
+  I2C0ID0 = (0x50) << 1; //(0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+  I2C0STX = 0x00;
+  I2C0STX = 0x00;
+
+  // assignation of the different pointers for the I2C exchange of data
+  for (k = 0; k < 16; k++) {
+    plist[k] = (unsigned char * )(BigDat + k * 16);
+    plist[k + 50] = (unsigned char * )(text + k * 32);
+  }
+
+  for (i = 0; i < BIGDAT_SZ; i++)
+    BigDat[i] = 0;
+
+  sprintf(text, "pulse stabilization v2.0 => %s\ncompiled: %s\nbecause we can!", __func__, __DATE__);
+
+  for (k = 0; k < 4; k++) {
+    plist[100 + k] = (unsigned char * )(Vout + k);
+  }
+
+  // 104	to execute the function get_DACs
+  // 105	to execute the function set_DACs
+
+  plist[110] = (unsigned char * ) & Vlearn;
+  plist[111] = (unsigned char * ) & Vin;
+  plist[112] = (unsigned char * ) & Vin_gnd;
+  plist[113] = (unsigned char * ) & wf_cnt;
+  plist[114] = (unsigned char * ) & v_cnt;
+  plist[115] = (unsigned char * ) & remote_trigg;
+
+  plist[120] = (unsigned char * ) & I2C0ID0;
+  plist[121] = (unsigned char * ) & ADCCP;
+  plist[122] = (unsigned char * ) & transf;
+  plist[123] = (unsigned char * ) & wf_len;
+  plist[124] = (unsigned char * ) & trigg_cnt;
+
+  plist[125] = (unsigned char * ) & Vset;
+  plist[126] = (unsigned char * ) & N;
+  plist[127] = (unsigned char * ) & start;
+  plist[128] = (unsigned char * ) & stop;
+  //plist[129] = (unsigned char*)&start2;	  //not in use
+  //plist[130] = (unsigned char*)&stop2;  //not in use
+  plist[129] = (unsigned char * ) & auto_set_pga;
+  plist[130] = (unsigned char * ) & coarse_fine_ratio;
+  plist[131] = (unsigned char * ) & start_gnd;
+  plist[132] = (unsigned char * ) & stop_gnd;
+  plist[133] = (unsigned char * ) & enab_gnd;
+  plist[134] = (unsigned char * ) & Gain;
+  plist[135] = (unsigned char * ) & step_max;
+  plist[136] = (unsigned char * ) & pga_state;
+  // 137; 138 for running set_pga and get_pga commands
+  plist[139] = (unsigned char * ) & mode;
+  plist[140] = (unsigned char * ) & coarse_fine_ratio;
+  plist[141] = (unsigned char * ) & out_of_lock;
+
+  // Dummy DAC initialization
+  DAC0DAT = DATtoADC(10);
+  DAC1DAT = DATtoADC(20);
+  DAC2DAT = DATtoADC(2000);
+  DAC3DAT = DATtoADC(40);
+  Vout[3] = 111;
+  set_DACs();
+
+  // LOOP FOR LEARNING AND LOCKING //////////////////////
+  while (1) {
+    // trigg in is on p0.3 => we check that it is low first (rising edge detection)
+    if ((((GP0DAT & 0x000000FF) >> 3) & 0x1) == 0) {
+      armed = 1;
+    }
+
+    // now p0.3 is high => this is our rising edge
+    if (((((GP0DAT & 0x000000FF) >> 3) & 0x1) == 1 && armed == 1) || remote_trigg) {
+      armed = 0;
+      trigg_cnt++;
+
+      // Measure signal
+      for (k = 0; k < wf_len; k++) {
+        while (!ADCSTA) {} // wait for the end of ADC conversion
+        Data[k] = (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+      }
+
+      if (busy == 0) { // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+        //*** copy for the i2c ***
+        memcpy(BigDat, Data, 256 * sizeof(short)); // Takes around 20 microseconds
+
+        wf_cnt++;
+        cnt_N++;
+
+        //sum of the data
+        for (k = start; k < stop; k++) {
+          sum += Data[k];
+        }
+        for (k = start_gnd; k < stop_gnd; k++) {
+          sum_gnd += Data[k];
+        }
+
+        // If we have already measured the N waveforms we need, find 
+        if (cnt_N >= N) { // Can take up to 80 microseconds
+          Vin = ((double) sum) / (cnt_N * (stop - start)); // calculate signal average value
+          Vin_gnd = ((double) sum_gnd) / (cnt_N * (stop_gnd - start_gnd)); // calculate background average value
+          valid_data = 1;
+          v_cnt++;
+          sum = 0; // re-initialization of the measurement
+          sum_gnd = 0;
+          cnt_N = 0;
+        }
+      } else busy = 0;
+
+      //*** feedback *** (mode is on pin p0.6)
+
+      // LOCK MODE
+      if ((((GP0DAT & 0x000000FF) >> 6) & 0x1) == 1) {
+        mode = 1; // Locking
+        if (valid_data == 1) {
+          valid_data = 0; // Restart measurements
+          cnt_N = 0;
+
+          // Calculate necessary step and update fine output
+          step = (Vset - Vin + Vin_gnd * enab_gnd) * Gain;
+          if (step > step_max)
+            step = step_max;
+          else if (step < -step_max)
+            step = -step_max;
+          Vout2 = Vout2 + step;
+
+          // Adjust coarse output if necessary
+          if (Vout2 < 2000 || Vout2 > 4000) {
+            Vout1 = Vout1 + (Vout2 - 3000) / coarse_fine_ratio;
+            Vout2 = 3000;
+          }
+
+          // Check if we're out of range
+          if (Vout1 > 4095) {
+            out_of_lock = 1;
+            Write_Digital(0, 1);
+            Vout1 = 4095;
+          } else {
+            out_of_lock = 0;
+            Write_Digital(0, 0);
+          }
+
+          // Set output
+          DAC1DAT = DATtoADC(Vout1); // output voltage, coarse
+          DAC2DAT = DATtoADC(Vout2); // output voltage, fine
+        }
+      }
+
+      // LEARN MODE
+      else {
+        mode = 0; // Learning
+
+        // Save the current input level as the set point of the next locking 
+        if (valid_data == 1) {
+          valid_data = 0;
+          Vset = Vin - Vin_gnd * enab_gnd;
+          cnt_N = 0;
+        }
+        Vout1 = Vlearn; // Coarse output = Vlearn, fine output is free.
+
+        // Automatically find input gain and offset
+        if (auto_set_pga == 1) {
+          get_DACs();
+          Vout0 = Vout[0];
+          if (Vin_gnd < 30 && Vout0 < 4095) { //may clip, shift up
+            Vout0++;
+            DAC0DAT = DATtoADC(Vout0);
+          } else if (Vin_gnd > 100 && Vout0 > 0) { //shift down
+            Vout0--;
+            DAC0DAT = DATtoADC(Vout0);
+          } else if (Vin > 4000) { //too big, may clip
+            if ((pga_state - 8) / 16 > 0) pga_state -= 16;
+            set_pga();
+            //else: too big even with no gain?
+          } else if (Vin < 2000) { //too small
+            if ((pga_state - 8) / 16 < 7) pga_state += 16;
+            set_pga();
+          }
+        }
+
+        // Set output
+        DAC1DAT = DATtoADC(Vout1);
+        // Do not set Vout2 so that we can scan it
+
+      }
+    }
+  }
+}
+
+int main(void) {
+  lock_StabPulse_i2c();
+  return 0;
+}
+
+///////////////////////////////////////
+// IRQ Service Routine
+///////////////////////////////////////
+
+void My_IRQ_Handler() {
+  int status = I2C0SSTA;
+  busy = 1;
+
+  // Slave Recieve
+  if ((status & 0x08) == 0x08) {
+    if (first == 1) {
+      first = 0;
+      Byte_addr = I2C0SRX;
+      I2C0FSTA |= 1 << 8;
+
+      i2c_cnt = 0;
+      if (Byte_addr == 122)
+        transf = 1;
+      if (Byte_addr == 104)
+        get_DACs();
+      if (Byte_addr == 105)
+        set_DACs();
+      if (Byte_addr == 137)
+        set_pga();
+      if (Byte_addr == 138)
+        get_pga();
+
+      //Write_Digital(2, 0);
+      pbuff = plist[Byte_addr];
+      I2C0STX = pbuff[0];
+
+    } else {
+      pbuff[i2c_cnt] = I2C0SRX;
+      i2c_cnt++;
+    }
+  }
+
+  // Slave Transmit
+  else if ((status & 0x04) == 0x04) // Slave Transmit IRQ
+  {
+    i2c_cnt++;
+    I2C0STX = pbuff[i2c_cnt];
+    I2C0ADR = 0xA1;
+    //if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+    //set_DACs();
+  } else if ((status & 0x0400) == 0x0400) //
+  {
+    first = 1;
+    //Write_Digital(2,1);
+  }
+
+  busy = 1;
+}

+ 439 - 0
microcontroller/Demo1p2.C

@@ -0,0 +1,439 @@
+/*
+
+    v1.2
+	
+	
+	this program use old code used in another experiment
+    
+    "int" is used for the ADC and DAC data although it should be unsigned, 
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short Vlearn;
+
+double Vin,Vin_gnd;
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned char transf,enab_gnd,busy,remote_trigg;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+float Gain;
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else 
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N;
+	double sum,sum_gnd;
+	unsigned short Vout2;
+	//double Vin,Vin_gnd;
+	//int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	short valid_data;
+	int k;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+
+	// locking parameters initialization
+//	cnt = 0;      // 
+	N = 10;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vin_gnd = 0;
+//	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 200;
+	Vset = 200;
+	Vlearn = 2000;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v1.2 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+	
+	plist[110] = (unsigned char*)&Vlearn;
+	plist[111] = (unsigned char*)&Vin;
+	plist[112] = (unsigned char*)&Vin_gnd;
+	plist[113] = (unsigned char*)&wf_cnt;
+	plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;	
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	
+		
+	
+		
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+	
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	wf_cnt = 0;
+	v_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+	remote_trigg = 0;
+	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+	
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+			
+			armed = 0;
+			//busy = 0;	
+			//*** aquisition of the waveform  ***
+			/*for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				tmp_dat[k]= ADCDAT; // read voltage from ADC0
+			}
+			for(k=0;k<wf_len;k++){
+				Data[k]= (tmp_dat[k]&0xFFF0000)>>16; // read voltage from ADC0
+			
+			}*/
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+			}
+			
+			trigg_cnt++;
+
+			if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+				//*** copy for the i2c ***			
+				memcpy(BigDat,Data,256*sizeof(short));
+				wf_cnt++;
+				
+				cnt_N++;
+						
+				//sum of the data
+				for(k=start;k<stop;k++){
+					sum += Data[k];
+					//cnt++;
+				}
+				for(k=start_gnd;k<stop_gnd;k++){
+					sum_gnd += Data[k];
+					//cnt_gnd++;
+				}
+				if(cnt_N>=N){
+					Vin = sum/(cnt_N*(stop-start));	// calculate average value
+					Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+					valid_data = 1;
+					v_cnt++;
+					sum = 0; // initialization	of the measurement
+					sum_gnd = 0;
+					cnt_N = 0;
+				}
+			}
+			else busy = 0;
+			
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			// LOCK MODE
+			if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(valid_data==1){
+					valid_data=0;
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}	 		
+				}
+			}
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			else{
+				if(valid_data==1){
+					valid_data=0;
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout2 = Vlearn;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC2DAT = DATtoADC(Vout2); // output voltage
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	busy=1;
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1203 - 0
microcontroller/Demo2016_05_13


+ 445 - 0
microcontroller/DemoHD.C

@@ -0,0 +1,445 @@
+/*
+
+    v1.2
+	
+	
+	this program use old code used in another experiment
+    
+    "int" is used for the ADC and DAC data although it should be unsigned, 
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short Vlearn;
+
+double Vin,Vin_gnd;
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned char transf,enab_gnd,busy,remote_trigg;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+float Gain;
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP1DAT=(0x00000001<<(n+16))|GP1DAT;
+	else 
+		GP1DAT=~((0x00000001<<(n+16))|(~GP1DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N;
+	double sum,sum_gnd;
+	unsigned short Vout2;
+	//double Vin,Vin_gnd;
+	//int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	short valid_data;
+	int k;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	GP1CON = 0x00000000;    // IO initialization
+	GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+
+	// locking parameters initialization
+//	cnt = 0;      // 
+	N = 10;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vin_gnd = 0;
+//	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 200;
+	Vset = 200;
+	Vlearn = 2000;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v1.2 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+	
+	plist[110] = (unsigned char*)&Vlearn;
+	plist[111] = (unsigned char*)&Vin;
+	plist[112] = (unsigned char*)&Vin_gnd;
+	plist[113] = (unsigned char*)&wf_cnt;
+	plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;	
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	
+		
+	
+		
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+	
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	wf_cnt = 0;
+	v_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+	remote_trigg = 0;
+	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+	
+
+		Write_Digital(4,0);
+		delay(4000);
+		Write_Digital(4,1);
+		delay(30000);
+
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+			
+			armed = 0;
+			//busy = 0;	
+			//*** aquisition of the waveform  ***
+			/*for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				tmp_dat[k]= ADCDAT; // read voltage from ADC0
+			}
+			for(k=0;k<wf_len;k++){
+				Data[k]= (tmp_dat[k]&0xFFF0000)>>16; // read voltage from ADC0
+			
+			}*/
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+			}
+			
+			trigg_cnt++;
+
+			if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+				//*** copy for the i2c ***			
+				memcpy(BigDat,Data,256*sizeof(short));
+				wf_cnt++;
+				
+				cnt_N++;
+						
+				//sum of the data
+				for(k=start;k<stop;k++){
+					sum += Data[k];
+					//cnt++;
+				}
+				for(k=start_gnd;k<stop_gnd;k++){
+					sum_gnd += Data[k];
+					//cnt_gnd++;
+				}
+				if(cnt_N>=N){
+					Vin = sum/(cnt_N*(stop-start));	// calculate average value
+					Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+					valid_data = 1;
+					v_cnt++;
+					sum = 0; // initialization	of the measurement
+					sum_gnd = 0;
+					cnt_N = 0;
+				}
+			}
+			else busy = 0;
+			
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			// LOCK MODE
+			if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(valid_data==1){
+					valid_data=0;
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}	 		
+				}
+			}
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			else{
+				if(valid_data==1){
+					valid_data=0;
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout2 = Vlearn;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC2DAT = DATtoADC(Vout2); // output voltage
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	busy=1;
+}

+ 569 - 0
microcontroller/DemoMem.C

@@ -0,0 +1,569 @@
+/*
+
+    v1.2
+	
+	
+	this program use old code used in another experiment
+    
+    "int" is used for the ADC and DAC data although it should be unsigned, 
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short Vlearn;
+
+double Vin,Vin_gnd;
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned short int FEE_addr;
+
+unsigned char transf,enab_gnd,busy,remote_trigg;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+unsigned short test;
+
+unsigned short probe;
+
+float Gain;
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+
+unsigned char ERROR;
+unsigned int status, uiTest, uiTest1, uiTest2;
+unsigned short ucVerifyTest = 0;
+
+#pragma pack(1)
+
+struct Test
+{
+   char AA;
+   int BB;
+   char CC;
+};
+
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else 
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+
+
+
+
+
+
+void protect_page(unsigned int addr){
+	FEEADR = 0x1234;			 		// Key
+	FEEDAT = 0x1234;					// Key
+	FEEPRO = addr;
+	FEEMOD = 0x48;
+	FEECON = 0x0C;
+	status = FEESTA&0x03;
+	while (!(status)) status = FEESTA&0x03;
+	if ((status&0x02)==0x02) //ERROR = 1;
+	return;								// return 
+} 
+
+
+unsigned short load(unsigned short int addr){
+	FEEADR = addr;
+	FEECON = 0x01;				// single read command
+	status = FEESTA;
+	probe = status;
+	while ((status&0x04)==0x04) status = FEESTA;
+	if ((status&0x02)==0x02){ 
+		return 66; 
+//		ERROR = 1;
+	}
+	return (FEEDAT);		
+} 
+
+
+void save(unsigned short int addr, unsigned short data){
+	
+	//FEEMOD = 0x8;
+	
+	FEEADR = addr;				// set data address
+	FEEDAT = data;				// set data value
+	FEECON = 0x02;				// single Write command
+	status = FEESTA;
+	probe = status;
+	while ((status&0x04)==0x04) status = FEESTA;
+	if ((status&0x02)==0x02) ERROR = 0;
+
+	//FEEMOD = 0x0;
+	//protect_page(0xBFFFFFFF);
+
+	return;
+}
+
+
+void erase_page(unsigned short int addr){
+	FEEADR = addr;				// set data address
+	FEECON = 0x05;				// erase page command
+	status = FEESTA;
+	probe = status;
+	while ((status&0x04)==0x04) status = FEESTA;
+	if ((status&0x02)==0x02) ERROR = 0;
+ 	return;
+}
+
+
+
+void init(void)
+{
+	test = load(FEE_addr);
+
+}
+
+void erase(void)
+{
+    erase_page(FEE_addr);		  	// erase page 120
+
+
+}
+
+void update(void)
+{
+
+	save(FEE_addr, test);
+		 
+	//protect_page(0xBFFFFFFF);	 // protect pages
+}	
+
+
+
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N;
+	double sum,sum_gnd;
+	unsigned short Vout2;
+	//double Vin,Vin_gnd;
+	//int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	short valid_data;
+	int k;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+	
+
+	FEEMOD = 0x8;
+	delay(20);
+
+	FEE_addr = 0xF000;
+
+	//init();
+
+	//FEEPRO = 0x40000000;
+
+	//test=0;
+	// locking parameters initialization
+//	cnt = 0;      // 
+	N = 10;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vin_gnd = 0;
+//	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 200;
+	Vset = 200;
+	Vlearn = 2000;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v1.2 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+	
+	plist[110] = (unsigned char*)&Vlearn;
+	plist[111] = (unsigned char*)&Vin;
+	plist[112] = (unsigned char*)&Vin_gnd;
+	plist[113] = (unsigned char*)&wf_cnt;
+	plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;	
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	plist[141] = (unsigned char*)&test;
+	plist[142] = (unsigned char*)&probe;
+	
+	plist[140] = (unsigned char*)&FEE_addr;
+	
+		
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+	
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	wf_cnt = 0;
+	v_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+	remote_trigg = 0;
+	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+	
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+			
+			armed = 0;
+			//busy = 0;	
+			//*** aquisition of the waveform  ***
+			/*for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				tmp_dat[k]= ADCDAT; // read voltage from ADC0
+			}
+			for(k=0;k<wf_len;k++){
+				Data[k]= (tmp_dat[k]&0xFFF0000)>>16; // read voltage from ADC0
+			
+			}*/
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+			}
+			
+			trigg_cnt++;
+
+			if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+				//*** copy for the i2c ***			
+				memcpy(BigDat,Data,256*sizeof(short));
+				wf_cnt++;
+				
+				cnt_N++;
+						
+				//sum of the data
+				for(k=start;k<stop;k++){
+					sum += Data[k];
+					//cnt++;
+				}
+				for(k=start_gnd;k<stop_gnd;k++){
+					sum_gnd += Data[k];
+					//cnt_gnd++;
+				}
+				if(cnt_N>=N){
+					Vin = sum/(cnt_N*(stop-start));	// calculate average value
+					Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+					valid_data = 1;
+					v_cnt++;
+					sum = 0; // initialization	of the measurement
+					sum_gnd = 0;
+					cnt_N = 0;
+				}
+			}
+			else busy = 0;
+			
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			// LOCK MODE
+			if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(valid_data==1){
+					valid_data=0;
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}	 		
+				}
+			}
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			else{
+				if(valid_data==1){
+					valid_data=0;
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout2 = Vlearn;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC2DAT = DATtoADC(Vout2); // output voltage
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104){
+//					get_DACs();
+					init();
+				}
+				if(Byte_addr==105){
+//					set_DACs();
+					update();
+				}
+				if(Byte_addr==106)
+					erase();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	busy=1;
+}

+ 390 - 0
microcontroller/DemoPSD1p0.C

@@ -0,0 +1,390 @@
+/*
+
+    v1.0
+	
+	PSD
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+//short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+//unsigned short Vlearn;
+
+double Vin[5];
+
+unsigned short remote_trigg,wf_len; 
+
+//unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset, step_max,N;
+
+unsigned char busy,channel;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else 
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+//	unsigned int cnt_N;
+	double sum;//,sum_gnd;
+//	unsigned short Vout2;
+	//double Vin,Vin_gnd;
+	//int Vmean;
+//	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+//	short valid_data;
+	int k,i;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+
+	// locking parameters initialization
+//	cnt = 0;      // 
+//	N = 1;       // number of measume,ts for averaging
+//	Vin = 0;      // initialize the voltage of first step
+//	Vin_gnd = 0;
+//	Vmean = 2000;
+//	start = 20;	
+//	stop = 30;
+//	start_gnd = 0;
+//	stop_gnd = 10;
+	wf_len = 200;
+//	Vset = 200;
+//	Vlearn = 2000;
+//	step = 50;
+//	step_max = 100;
+//	Gain = 1;
+
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v1.2 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+	
+	//plist[110] = (unsigned char*)&(Vin[0]);
+	//plist[111] = (unsigned char*)&(Vin[1]);
+	//plist[112] = (unsigned char*)&(Vin[2]);
+	//plist[113] = (unsigned char*)&(Vin[3]);
+	//plist[114] = (unsigned char*)&(Vin[4]);
+	for (k=0;k<5;k++){
+		plist[110+k] = (unsigned char*)(Vin+k);
+	}
+	
+	//plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;	
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&channel;
+//	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+//	plist[125] = (unsigned char*)&Vset;
+//	plist[126] = (unsigned char*)&N;
+//	plist[127] = (unsigned char*)&start;
+//	plist[128] = (unsigned char*)&stop;
+//	plist[129] = (unsigned char*)&start2;
+//	plist[130] = (unsigned char*)&stop2;
+//	plist[131] = (unsigned char*)&start_gnd;
+//	plist[132] = (unsigned char*)&stop_gnd;
+//	plist[133] = (unsigned char*)&enab_gnd;
+//	plist[134] = (unsigned char*)&Gain;
+//	plist[135] = (unsigned char*)&step_max;
+	
+		
+	
+		
+//	DAC0DAT = DATtoADC(10);
+//	DAC1DAT = DATtoADC(20);
+//	DAC2DAT = DATtoADC(2000);
+//	DAC3DAT = DATtoADC(40);
+	
+//	Vset=0;
+
+//	Vout[3] = 111;
+//	set_DACs();
+
+//	transf = 0;
+//	trigg_cnt = 0;
+//	wf_cnt = 0;
+//	v_cnt = 0;
+//	cnt_N = 0;
+//	enab_gnd = 0;
+	remote_trigg = 0;
+	channel = 0;
+//	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+	
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+			
+			armed = 0;
+			//busy = 0;	
+			//*** aquisition of the waveform  ***
+			
+		 
+			for(i=1;i<5;i++){
+				ADCCP = i;			
+			
+				for(k=0;k<wf_len;k++){
+					while(!ADCSTA){}	// wait for the end of ADC conversion
+					Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+				}
+			
+				
+				//if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+					//*** copy for the i2c ***			
+				
+					if(i==channel){
+						memcpy(BigDat,Data,256*sizeof(short));
+					}
+						
+					sum = 0; // initialization	of the measurement
+					for(k=0;k<wf_len;k++){
+						sum += Data[k];
+					//cnt++;
+					}
+				
+					Vin[i] = sum/wf_len;	// calculate average value
+//					valid_data = 1;
+				
+				//}
+//				else busy = 0;
+			} 
+			remote_trigg=0;
+			
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+//				if(Byte_addr==122)
+//					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	busy=1;
+}

+ 488 - 0
microcontroller/Demo_original.C

@@ -0,0 +1,488 @@
+/*
+
+    v2.0
+	
+	
+	this program use old code used in another experiment
+    
+    "int" is used for the ADC and DAC data although it should be unsigned, 
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short Vlearn;
+
+double Vin,Vin_gnd;
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned char transf,enab_gnd,busy,remote_trigg;
+
+unsigned int trigg_cnt,v_cnt,wf_cnt;
+
+float Gain;
+
+
+unsigned char pga_state = 0x08; // gain 1 channel 8
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else 
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+
+void set_pga(){
+	
+	SPITX = 0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+	
+	SPITX = pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	
+}
+
+
+void get_pga(){
+	
+	SPITX = 0x7A;//0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+	
+	SPITX = 0;//pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+
+	delay(500);
+	
+	SPITX = 0;//0x3A;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+	
+	SPITX = 0;//pga_state;				  // transmit command or any dummy data
+ 	while ((SPISTA & 0x02) != 0x02) ; // wait for data received status bit
+	
+}
+
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N;
+	double sum,sum_gnd;
+	unsigned short Vout2;
+	//double Vin,Vin_gnd;
+	//int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	short valid_data;
+	int k;
+	unsigned short Data[256];
+	//unsigned int tmp_dat[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+
+	// locking parameters initialization
+//	cnt = 0;      // 
+	N = 10;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vin_gnd = 0;
+//	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 200;
+	Vset = 200;
+	Vlearn = 2000;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+	
+	GP1CON = 0x22220022;				// configure SPI such the P1.0 and P1.1 are set for I2C0
+										// P1.2 and P1.3 are set for GPIO (connected on 50Ohms driver TTL)
+										// P1.4-7 on SPI
+	SPIDIV = 0xCC;						// set SPI clock 40960000/(2x(1+SPIDIV))
+										// 0xCC = 100kHz
+										// 
+	SPICON = 0x1043;					// enable SPI master in continuous transfer mode 
+										// slave select will stay low during the all transmission
+	
+	
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50)<<1;//(0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization v2.0 => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104	to execute the function get_DACs
+	// 105	to execute the function set_DACs
+	
+	plist[110] = (unsigned char*)&Vlearn;
+	plist[111] = (unsigned char*)&Vin;
+	plist[112] = (unsigned char*)&Vin_gnd;
+	plist[113] = (unsigned char*)&wf_cnt;
+	plist[114] = (unsigned char*)&v_cnt;
+	plist[115] = (unsigned char*)&remote_trigg;	
+
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	plist[136] = (unsigned char*)&pga_state;
+	
+		
+	
+		
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+	
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	wf_cnt = 0;
+	v_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+	remote_trigg = 0;
+	valid_data=0;
+
+
+	// main loop for the locking
+	while(1){
+		
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if(((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1) || remote_trigg){
+			
+			armed = 0;
+			//busy = 0;	
+			//*** aquisition of the waveform  ***
+			/*for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				tmp_dat[k]= ADCDAT; // read voltage from ADC0
+			}
+			for(k=0;k<wf_len;k++){
+				Data[k]= (tmp_dat[k]&0xFFF0000)>>16; // read voltage from ADC0
+			
+			}*/
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (unsigned short)(ADCDAT >> 16); // read voltage from ADC0
+			}
+			
+			trigg_cnt++;
+
+			if(busy==0){ // supposed to guaranty that no i2c transfer has been performed during the wf acquisition
+				//*** copy for the i2c ***			
+				memcpy(BigDat,Data,256*sizeof(short));
+				wf_cnt++;
+				
+				cnt_N++;
+						
+				//sum of the data
+				for(k=start;k<stop;k++){
+					sum += Data[k];
+					//cnt++;
+				}
+				for(k=start_gnd;k<stop_gnd;k++){
+					sum_gnd += Data[k];
+					//cnt_gnd++;
+				}
+				if(cnt_N>=N){
+					Vin = sum/(cnt_N*(stop-start));	// calculate average value
+					Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+					valid_data = 1;
+					v_cnt++;
+					sum = 0; // initialization	of the measurement
+					sum_gnd = 0;
+					cnt_N = 0;
+				}
+			}
+			else busy = 0;
+			
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			// LOCK MODE
+			/*if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(valid_data==1){
+					valid_data=0;
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}	 		
+				}
+			}*/
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			/*else{
+				if(valid_data==1){
+					valid_data=0;
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout2 = Vlearn;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC2DAT = DATtoADC(Vout2); // output voltage
+			*/
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	busy = 1;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+				if(Byte_addr==137)
+					set_pga();
+				if(Byte_addr==138)
+					get_pga();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	busy=1;
+}

+ 410 - 0
microcontroller/Demov1p0.C

@@ -0,0 +1,410 @@
+/*
+
+    v1.0
+	
+    "int" is used for the ADC and DAC data although it should be unsigned, 
+    it should be not a problem at all as this data are limited to 12bits...
+
+
+
+*/
+
+#include<ADuC7020.h>
+#include<stdlib.h>
+#include<stdio.h>
+#include<string.h>
+
+void My_IRQ_Handler(void);
+
+short i = 0;
+unsigned char Byte_addr = 0;
+int first = 1;
+int i2c_cnt = 0;
+
+#define BIGDAT_SZ 256
+unsigned short BigDat[BIGDAT_SZ];
+char text[512];
+
+unsigned short Vout[4];
+
+unsigned short start, stop,start_gnd,stop_gnd,start2,stop2,Vset,wf_len, step_max,N;
+
+unsigned char transf,enab_gnd;
+
+unsigned int trigg_cnt;
+
+float Gain;
+
+
+//char format	= 0;
+
+
+unsigned char* pbuff;
+
+unsigned char* plist[256];
+
+
+
+void delay (int length)
+{
+	while (length >=0)
+    	length--;
+}
+
+
+// conversion of the read value into it corresponding 12bits integer
+int ADCtoDAT(unsigned long ADC)
+{
+	return (ADC&0xFFF0000)>>16;
+}
+
+unsigned long DATtoADC(int DAT)
+{
+	unsigned long ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+unsigned long DATtoDAC(unsigned short DAT)
+{
+	unsigned int ADC;
+	ADC=DAT;
+	return ADC<<16;
+}
+
+
+int Read_Digital(int n)
+{	
+    return ((GP0DAT&0x000000FF)>>n)&0x1;
+}
+
+void Write_Digital(int n, int state)
+{	
+    if(state==1)
+	  GP2DAT=(0x00000001<<(n+16))|GP2DAT;
+	else 
+		GP2DAT=~((0x00000001<<(n+16))|(~GP2DAT));
+}
+
+
+void ADCpoweron(int time)
+{
+	ADCCON = 0x620;	 			// power-on the ADC
+	while (time >=0)	  		// wait for ADC to be fully powered on
+    time--;
+}
+
+
+
+
+void get_DACs(void)
+{
+	Vout[0]=DAC0DAT>>16;
+	Vout[1]=DAC1DAT>>16;
+	Vout[2]=DAC2DAT>>16;
+	Vout[3]=DAC3DAT>>16;	
+}
+
+void set_DACs(void)
+{
+	DAC0DAT=DATtoDAC(Vout[0]);
+	DAC1DAT=DATtoDAC(Vout[1]);
+	DAC2DAT=DATtoDAC(Vout[2]);
+	DAC3DAT=DATtoDAC(Vout[3]);
+}
+
+void lock_StabPulse_i2c(void)
+{
+	// define variables
+	unsigned int cnt_N, tg_cnt;
+	double sum,sum_gnd;
+	unsigned short Vout2;
+	double Vin,Vin_gnd;
+	int Vmean;
+	int step = 100;
+	short armed; // this is used to detect the trigger : 
+				 // when the trigger input is low armed is set to 1
+				 // when a measurement start it is set to 0
+	
+	int k;
+	unsigned short Data[256];
+
+
+	POWKEY1 = 0x01;
+	POWCON = 0x00;		   				// 41.78MHz
+	POWKEY2 = 0xF4;
+	 
+
+	//GP1CON = 0x00000000;    // IO initialization
+	//GP1DAT = 0xFF000000;	// set P1.n as digital output
+	
+	GP0CON = 0x00000000;	// IO initialization
+	//GP0DAT = 0x00000000;	// set P0.n as digital input
+
+
+
+	// ADC&DAC setting
+	ADCpoweron(20000); // power on ADC
+	REFCON = 0x01;	   // internal 2.5V reference
+	DAC0CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC2CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	DAC3CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	ADCCP = 0x03;	   // conversion on ADC0
+	ADCCON = 0x3E4;    // continuous conversion
+
+	// IO setting
+    GP2CON = 0x00000000;    // IO initialization
+	GP2DAT = 0xFF000000;	// set P2.n as digital output
+	GP0CON = 0x00000000;	// IO initialization
+	GP0DAT = 0x00000000;	// set P0.n as digital input
+	
+
+	// locking parameters initialization
+//	cnt = 0;      // 
+	N = 50;       // number of measume,ts for averaging
+	Vin = 0;      // initialize the voltage of first step
+	Vmean = 2000;
+	start = 20;
+	stop = 30;
+	start_gnd = 0;
+	stop_gnd = 10;
+	wf_len = 256;
+	Vset = 10;
+	step = 50;
+	step_max = 100;
+	Gain = 1;
+
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ = My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x04001;
+	// Slave ID		  		
+	I2C0ID0 = (0x50 + (((GP0DAT&0x000000FF)>>5)&0x1)+(((GP0DAT&0x000000FF)>>7)&0x1)*2)<<1;
+	I2C0STX = 0x00;
+	I2C0STX = 0x00;
+
+	// assignation of the different pointers for the I2C exchange of data
+	for (k=0;k<16;k++){
+		plist[k] = (unsigned char*)(BigDat+k*16);
+		plist[k+50] = (unsigned char*)(text+k*32);
+	}
+	
+	for(i=0;i<BIGDAT_SZ;i++)
+		BigDat[i]=0;
+
+	sprintf(text,"pulse stabilization => %s\ncompiled: %s\nbecause we can!",__func__,__DATE__);
+	
+	for (k=0;k<4;k++){
+		plist[100+k] = (unsigned char*)(Vout+k);
+	}
+	// 104
+	// 105
+	
+	plist[120] = (unsigned char*)&I2C0ID0;
+	plist[121] = (unsigned char*)&ADCCP;
+	plist[122] = (unsigned char*)&transf;
+	plist[123] = (unsigned char*)&wf_len;
+	plist[124] = (unsigned char*)&trigg_cnt;
+
+	plist[125] = (unsigned char*)&Vset;
+	plist[126] = (unsigned char*)&N;
+	plist[127] = (unsigned char*)&start;
+	plist[128] = (unsigned char*)&stop;
+	plist[129] = (unsigned char*)&start2;
+	plist[130] = (unsigned char*)&stop2;
+	plist[131] = (unsigned char*)&start_gnd;
+	plist[132] = (unsigned char*)&stop_gnd;
+	plist[133] = (unsigned char*)&enab_gnd;
+	plist[134] = (unsigned char*)&Gain;
+	plist[135] = (unsigned char*)&step_max;
+	
+	
+		
+	DAC0DAT = DATtoADC(10);
+	DAC1DAT = DATtoADC(20);
+	DAC2DAT = DATtoADC(2000);
+	DAC3DAT = DATtoADC(40);
+	
+	Vset=0;
+
+	Vout[3] = 111;
+	set_DACs();
+
+	transf = 0;
+	trigg_cnt = 0;
+	tg_cnt = 0;
+	cnt_N = 0;
+	enab_gnd = 0;
+
+
+	// main loop for the locking
+	while(1){
+	
+		// trigg in is on p0.3 => we check that it is low first (rising edge detection)
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==0){
+			armed = 1;
+		}		
+
+		// now p0.3 is high => this is our rising edge
+		if((((GP0DAT&0x000000FF)>>3)&0x1)==1 && armed==1){
+			
+			armed = 0;	
+			//*** aquisition of the waveform  ***
+			for(k=0;k<wf_len;k++){
+				while(!ADCSTA){}	// wait for the end of ADC conversion
+				Data[k]= (ADCDAT&0xFFF0000)>>16; // read voltage from ADC0
+			}
+			tg_cnt++;
+			//*** copy for the i2c ***			
+			while(transf==1){} // we make sure that the data are not changed during the transfer
+			memcpy(BigDat,Data,256*sizeof(short));
+			trigg_cnt = tg_cnt;
+			
+			if (cnt_N==0){
+				sum = 0; // initialization	of the measurement
+				sum_gnd = 0;
+			}
+			cnt_N++;
+						
+
+			//sum of the data
+			for(k=start;k<stop;k++){
+				sum += Data[k];
+				//cnt++;
+			}
+			for(k=start_gnd;k<stop_gnd;k++){
+				sum_gnd += Data[k];
+				//cnt_gnd++;
+			}
+			if(cnt_N>=N){
+				Vin = sum/(cnt_N*(stop-start));	// calculate average value
+				Vin_gnd = sum_gnd/(cnt_N*(stop_gnd-start_gnd));	// calculate average value
+			}
+
+			//*** feedback *** (mode is on pin p0.6)
+
+			// LOCK MODE
+			if((((GP0DAT&0x000000FF)>>6)&0x1)==1){
+				if(cnt_N>=N){
+					cnt_N=0;
+					//cnt_gnd=0;
+					step = (Vset-Vin+Vin_gnd*enab_gnd)*Gain;
+					if (step>step_max)
+						step = step_max;
+					else if (step<-step_max)
+						step = -step_max;
+					Vout2 = Vout2 + step;
+					if(Vout2>4095){
+						Write_Digital(0,1);
+						Vout2 = 4090;
+					}
+					else{
+						Write_Digital(0,0);
+					}	 		
+				}
+			}
+
+			// LEARN MODE
+			// we set the outputs to the average voltage
+			// and save the current input level as the set point of the next locking enable
+			else{
+				if(cnt_N>=N){
+					Vset = Vin-Vin_gnd*enab_gnd;
+					cnt_N=0;
+				}
+				Vout2 = Vmean;
+			}
+
+			//this line could also be inserted in the if conditions and thus not set every loops
+			DAC2DAT = DATtoADC(Vout2); // output voltage
+		}
+		
+	}
+}
+
+
+
+
+int main(void)
+{ 
+	
+	lock_StabPulse_i2c();
+
+	return 0;
+}
+
+
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+
+void My_IRQ_Handler()
+{
+	int status = I2C0SSTA;
+	
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{			
+			if(first==1){
+				first=0;
+				Byte_addr=I2C0SRX;
+				I2C0FSTA|= 1 << 8;
+
+				i2c_cnt = 0;
+				if(Byte_addr==122)
+					transf = 1;
+				if(Byte_addr==104)
+					get_DACs();
+				if(Byte_addr==105)
+					set_DACs();
+
+				Write_Digital(2,0);
+				pbuff = plist[Byte_addr];
+				I2C0STX = pbuff[0];	
+			
+			}
+			else {
+				pbuff[i2c_cnt] = I2C0SRX;
+				i2c_cnt++;	
+			}		
+	}
+	
+	// Slave Transmit
+	else if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{
+		i2c_cnt ++;
+		I2C0STX = pbuff[i2c_cnt];
+		I2C0ADR = 0xA1;
+		//if(Byte_addr>=110 && Byte_addr<=113 && i2c_cnt==1)
+			//set_DACs();	   			   		
+	}
+	
+	else if((status & 0x0400)==0x0400)   // 
+	{
+		 first = 1;
+		 //Write_Digital(2,1);
+	}
+	
+	// either we transfer a waveform or some parameters
+	// and when it is done we should put back transf = 0
+	/*if((i2c_cnt>31 && Byte_addr==15) || (i2c_cnt>1 && Byte_addr>15)){
+		Write_Digital(2,1);
+		transf = 0;
+	} */
+	/*if(i2c_cnt>31 && Byte_addr==15){
+		Write_Digital(2,1);
+		transf = 0;
+	}*/
+}

+ 43 - 0
microcontroller/EOM_lock.Opt

@@ -0,0 +1,43 @@
+### uVision2 Project, (C) Keil Software
+### Do not modify !
+
+ cExt (*.c)
+ aExt (*.s*; *.src; *.a*)
+ oExt (*.obj)
+ lExt (*.lib)
+ tExt (*.txt; *.h; *.inc)
+ pExt (*.plm)
+ CppX (*.cpp)
+ DaveTm { 0,0,0,0,0,0,0,0 }
+
+Target (Target 1), 0x0004 // Tools: 'ARM-ADS'
+GRPOPT 1,(Source Group 1),1,0,0
+
+OPTFFF 1,1,2,0,0,1,1,0,<.\ADuC702x.s><ADuC702x.s> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,75,0,0,0,75,0,0,0,36,6,0,0,44,2,0,0 }
+OPTFFF 1,2,1,301989891,0,398,430,0,<.\Demo.C><Demo.C> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,25,0,0,0,25,0,0,0,102,4,0,0,59,1,0,0 }
+OPTFFF 1,3,1,0,0,0,0,0,<.\irq_arm.c><irq_arm.c> 
+
+ExtF <C:\Keil\ARM\INC\ADI\flash.h> 1,1,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,25,0,0,0,25,0,0,0,121,5,0,0,254,1,0,0 }
+ExtF <C:\Keil\ARM\INC\ADI\ADuC7020.h> 46,46,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,50,0,0,0,50,0,0,0,146,5,0,0,23,2,0,0 }
+ExtF <C:\Keil\ARM\Examples\EOM_lock\Demo2p0.C> 373,373,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,100,0,0,0,100,0,0,0,65,6,0,0,73,2,0,0 }
+
+TARGOPT 1, (Target 1)
+ ADSCLK=32768
+  OPTTT 1,1,1,0
+  OPTHX 1,65535,0,0,0
+  OPTLX 79,66,8,<.\>
+  OPTOX 16
+  OPTLT 1,1,1,0,1,1,0,1,0,0,0,0
+  OPTXL 1,1,1,1,1,1,1,0,0
+  OPTFL 1,0,1
+  OPTAX 255
+  OPTBL 0,(Data Sheet)<DATASHTS\ADI\ADUC702X_DS.PDF>
+  OPTDL (SARM.DLL)(-cADuC70)(DARMAD.DLL)(-pADuC7020)(SARM.DLL)(-cADuC70)(TARMAD.DLL)(-pADuC7020)
+  OPTDBG 48125,0,()()()()()()()()()() ()()()()
+  OPTKEY 0,(UL2ARM)(-U88308796 -O7 -C0 -FO7 -FD10000 -FC800 -FN1 -FF0ADuC702X -FS080000 -FL0F800)
+  OPTBB 0,0,1,1,0,0,0,0,0,0,<Demo.C>()()
+  OPTDF 0x2
+  OPTLE <>
+  OPTLC <>
+EndOpt
+

+ 102 - 0
microcontroller/EOM_lock.Uv2

@@ -0,0 +1,102 @@
+### uVision2 Project, (C) Keil Software
+### Do not modify !
+
+Target (Target 1), 0x0004 // Tools: 'ARM-ADS'
+
+Group (Source Group 1)
+
+File 1,2,<.\ADuC702x.s><ADuC702x.s>
+File 1,1,<.\Demo.C><Demo.C>
+File 1,1,<.\irq_arm.c><irq_arm.c>
+
+
+Options 1,0,0  // Target 'Target 1'
+ Device (ADuC7020)
+ Vendor (Analog Devices)
+ Cpu (IRAM(0x10000-0x11FFF) IROM(0x80000-0x8F7FF) CLOCK(32768) CPUTYPE(ARM7TDMI))
+ FlashUt ()
+ StupF ("Startup\ADI\ADuC702x.s" ("ADuC702x Startup Code"))
+ FlashDR (UL2ARM(-U88308796 -O7 -C0 -FO7 -FD10000 -FC800 -FN1 -FF0ADuC702X -FS080000 -FL0F800))
+ DevID (3677)
+ Rgf (ADuC7020.H)
+ Mem ()
+ C ()
+ A ()
+ RL ()
+ OH ()
+ DBC_IFX ()
+ DBC_CMS ()
+ DBC_AMS ()
+ DBC_LMS ()
+ UseEnv=0
+ EnvBin ()
+ EnvInc ()
+ EnvLib ()
+ EnvReg (ADI\)
+ OrgReg (ADI\)
+ TgStat=16
+ OutDir (.\)
+ OutName (EOM_lock)
+ GenApp=1
+ GenLib=0
+ GenHex=1
+ Debug=1
+ Browse=1
+ LstDir (.\)
+ HexSel=1
+ MG32K=0
+ TGMORE=0
+ RunUsr 0 0 <>
+ RunUsr 1 0 <>
+ BrunUsr 0 0 <>
+ BrunUsr 1 0 <>
+ CrunUsr 0 0 <>
+ CrunUsr 1 0 <>
+ SVCSID <>
+ GLFLAGS=1790
+ ADSFLGA { 243,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ ACPUTYP (ARM7TDMI)
+ RVDEV ()
+ ADSTFLGA { 0,12,0,2,99,0,0,66,0,0,0,0,0,0,0,0,0,0,0,0 }
+ OCMADSOCM { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ OCMADSIRAM { 0,0,0,1,0,0,32,0,0 }
+ OCMADSIROM { 1,0,0,8,0,0,248,0,0 }
+ OCMADSXRAM { 0,0,0,0,0,0,0,0,0 }
+ OCR_RVCT { 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,8,0,0,248,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,32,0,0,0,0,0,0,0,0,0,0,0 }
+ RV_STAVEC ()
+ ADSCCFLG { 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ ADSCMISC ()
+ ADSCDEFN ()
+ ADSCUDEF ()
+ ADSCINCD ()
+ ADSASFLG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ ADSAMISC ()
+ ADSADEFN ()
+ ADSAUDEF ()
+ ADSAINCD ()
+ PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ IncBld=1
+ AlwaysBuild=0
+ GenAsm=0
+ AsmAsm=0
+ PublicsOnly=0
+ StopCode=3
+ CustArgs ()
+ LibMods ()
+ ADSLDFG { 17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ ADSLDTA (0x00080000)
+ ADSLDDA (0x00010000)
+ ADSLDSC ()
+ ADSLDIB ()
+ ADSLDIC ()
+ ADSLDMC ()
+ ADSLDIF ()
+ ADSLDDW ()
+  OPTDL (SARM.DLL)(-cADuC70)(DARMAD.DLL)(-pADuC7020)(SARM.DLL)(-cADuC70)(TARMAD.DLL)(-pADuC7020)
+  OPTDBG 48125,0,()()()()()()()()()() ()()()()
+ FLASH1 { 9,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0 }
+ FLASH2 (BIN\UL2ARM.DLL)
+ FLASH3 ()
+ FLASH4 ()
+EndOpt
+

BIN
microcontroller/EOM_lock.axf


+ 26 - 0
microcontroller/EOM_lock.fed

@@ -0,0 +1,26 @@
+;#<FEEDBACK># ARM Linker, RVCT4.0 [Build 524]: Last Updated: Fri Mar 18 10:48:48 2016
+;VERSION 0.2
+;FILE demo.o
+Bound <= USED 0
+Copy <= USED 0
+Copy_S_and_H <= USED 0
+Copy_S_and_Hcnt <= USED 0
+Lock_min_fringe <= USED 0
+Lock_power <= USED 0
+Read_Digital <= USED 0
+Write_Digital <= USED 0
+delay <= USED 0
+lock_EOM <= USED 0
+lock_EOM2 <= USED 0
+lock_EOM_and_AOM <= USED 0
+lock_StabPulse <= USED 0
+lock_StabPulse2 <= USED 0
+ramp <= USED 0
+ramp_with_TTLin <= USED 0
+synchronizer <= USED 0
+synchronizer2 <= USED 0
+test_blink <= USED 0
+test_blink2 <= USED 0
+test_clock <= USED 0
+test_clock2 <= USED 0
+;FILE irq_arm.o

+ 605 - 0
microcontroller/EOM_lock.hex

@@ -0,0 +1,605 @@
+:020000040008F2
+:1000000018F09FE518F09FE518F09FE518F09FE5C0
+:1000100018F09FE5FFFFFFFF18F09FE518F09FE540
+:10002000400008006C0E08004C0E08008C0E080002
+:10003000AC0E0800FFFFFFFF0C0E08002C0E08009E
+:1000400068009FE50110A0E3041480E50110A0E31F
+:10005000081480E5F410A0E30C1480E550009FE53F
+:10006000DBF021E300D0A0E1800040E2D7F021E303
+:1000700000D0A0E1800040E2D1F021E300D0A0E177
+:10008000800040E2D2F021E300D0A0E1800040E215
+:10009000D3F021E300D0A0E1800040E210F021E3A2
+:1000A00000D0A0E101AB4DE208009FE510FF2FE179
+:1000B0000000FFFF500F0100BC000800000000EB33
+:1000C000340000EB2C008FE2000C90E800A08AE0E6
+:1000D00000B08BE001704AE20B005AE10000001A08
+:1000E0002C0000EB0F00BAE818E04FE2010013E328
+:1000F00003F0471013FF2FE110240000302400000C
+:10010000102052E27800B0287800A128FBFFFF8A77
+:10011000822EB0E13000B0283000A1280040904588
+:10012000004081451EFF2FE10030B0E30040B0E306
+:100130000050B0E30060B0E3102052E27800A12844
+:10014000FCFFFF8A822EB0E13000A12800308145FB
+:100150001EFF2FE17847C046730051E37D04000A7B
+:100160000000B0E31EFF2FE101C08FE21CFF2FE172
+:100170001FB502F063F9059886460FBC009C02B0DB
+:100180007047000001C08FE21CFF2FE130B47546BC
+:10019000AE4630BC70470000AB0400EB0210A0E19B
+:1001A000F0FFFFEB1CC09FE50FC08CE001001CE3DB
+:1001B0000DE08F120FE0A0011CFF2FE101C08FE2C4
+:1001C0001CFF2FE101F072F9480C00007847C0468F
+:1001D000EBFFFFEBBA0400EB0C009FE50C109FE572
+:1001E00004209FE508309FE51EFF2FE1D0080100A5
+:1001F000D00C0100D00801001EFF2FE10002A0E199
+:10020000200AA0E11EFF2FE10008A0E11EFF2FE160
+:100210000008A0E11EFF2FE10010A0E3E01B11E5A4
+:10022000FF1001E23100A0E1010000E21EFF2FE11A
+:100230000120A0E3100080E21200A0E1010051E3E0
+:100240000020A0E3C01B12E50000C11101008001E5
+:10025000C00B02E51EFF2FE1FF18A0E3620EA0E332
+:10026000FF1481E2000581E51EFF2FE1FF18A0E3E6
+:10027000FF1481E2042691E51C079FE52228A0E1F6
+:10028000B020C0E10C2691E52228A0E1B220C0E117
+:10029000142691E52228A0E1B420C0E11C1691E5C6
+:1002A0002118A0E1B610C0E11EFF2FE1E8069FE58E
+:1002B000B010D0E10128A0E1FF18A0E3FF1481E213
+:1002C000042681E5B220D0E10228A0E10C2681E5D8
+:1002D000B420D0E10228A0E1142681E5B600D0E1E7
+:1002E0000008A0E11C0681E51EFF2FE1FF08A0E346
+:1002F0003A10A0E3FF0480E2081A80E5001A90E5B6
+:10030000020011E3FCFFFF0A90169FE50110D1E502
+:10031000081A80E5001A90E5020011E3FCFFFF0ACD
+:100320001EFF2FE1FF08A0E37A10A0E3FF0480E2A4
+:10033000081A80E5001A90E5020011E3FCFFFF0AAD
+:100340000020A0E3082A80E5001A90E5020011E3EE
+:10035000FCFFFF0A082A80E5001A90E5020011E37D
+:10036000FCFFFF0A082A80E5001A90E5020011E36D
+:10037000FCFFFF0A1EFF2FE1FF08A0E330002DE97C
+:10038000FF0480E2041890E510369FE501C0A0E369
+:10039000002083E204C0C3E5284092E53C2092E5BA
+:1003A000080011E35B00000A241093E5010051E30B
+:1003B0005200001A0040A0E3244083E5081890E5AD
+:1003C0000010C3E54C1890E5011C81E34C1880E552
+:1003D000284083E50020D3E57A0052E302C0C3053C
+:1003E0003D00000AB0159FE5680052E30C00001ABA
+:1003F000045690E52558A0E1B050C1E10C5690E5B7
+:100400002558A0E1B250C1E1145690E52558A0E16D
+:10041000B450C1E11C5690E52558A0E1B650C1E1A9
+:100420002D0000EA690052E30C00001AB050D1E13F
+:100430000558A0E1045680E5B250D1E10558A0E18D
+:100440000C5680E5B450D1E10558A0E1145680E582
+:10045000B610D1E10118A0E11C1680E51E0000EAEB
+:10046000890052E30900001A3A10A0E3081A80E557
+:10047000001A90E5020011E3FCFFFF0A0110D3E52A
+:10048000081A80E5001A90E5020011E3FCFFFF0A5C
+:100490008A0052E31000001A7A10A0E3081A80E5DF
+:1004A000001A90E5020011E3FCFFFF0A084A80E50C
+:1004B000001A90E5020011E3FCFFFF0A084A80E5FC
+:1004C000001A90E5020011E3FCFFFF0A084A80E5EC
+:1004D000001A90E5020011E3FCFFFF0AC01B14E5BF
+:1004E0000117C1E3C01B04E5B4149FE5021191E7B5
+:1004F0003C1083E50010D1E50C1880E5100000EAFF
+:10050000080890E50400C2E7280093E5010080E2B6
+:10051000280083E50A0000EA040011E30600000A4F
+:10052000011084E2281083E50110D2E70C1880E561
+:10053000A110A0E31C1880E5010000EA010B11E303
+:1005400024C0831504C0C3E53000BDE81EFF2FE1C1
+:10055000F04F2DE9FFB8A0E385DF4DE20110A0E3E5
+:10056000FFB48BE204148BE50000A0E308048BE5E4
+:10057000F420A0E30C248BE5000C00E5622EA0E340
+:1005800000258BE58C148BE51210A0E300168BE59B
+:1005900008168BE510168BE518168BE50310A0E303
+:1005A00004158BE5F91FA0E300158BE5F80B00E5BA
+:1005B000FF14A0E3C01B00E5000C00E5E00B00E524
+:1005C000D8939FE50A10A0E3F63F8FE2B811C9E186
+:1005D000060093E8484089E2060084E8060093E8B4
+:1005E000504089E2060084E86430A0E3C810A0E32C
+:1005F000BA30C9E1BC10C9E1BE00C9E1B031C9E1FE
+:10060000B411C9E1B211C9E17D1EA0E3B810C9E17E
+:10061000FE15A0E3B631C9E1381089E58C139FE5DA
+:10062000FC1B00E5CC10A0E30C1A8BE54310A0E303
+:10063000011A81E2101A8BE574239FE5B31F4FE284
+:10064000001082E5021CA0E308108BE50110A0E376
+:10065000011981E22C188BE5A010A0E338188BE576
+:100660000C088BE50C088BE548339FE51010A0E3E0
+:10067000016B83E202CC46E2802283E0002186E720
+:1006800080228CE000E186E0011051E2010080E26E
+:10069000C8208EE5F7FFFF1A18039FE5021CA0E3B0
+:1006A0007F0200EBF4929FE5010CA0E3B600C9E1E4
+:1006B00010239FE54C039FE5BF3F8FE2C21F8FE2EF
+:1006C000020200EB420089E2940186E5440089E2DF
+:1006D000980186E5460089E29C0186E5080089E2EA
+:1006E000B80186E5480089E2BC0186E5500089E250
+:1006F000C00186E5340089E2C40186E5300089E264
+:10070000C80186E5050089E2CC0186E53800A0E352
+:100710003E0B40E2E00186E5CD0F40E2E40186E5D4
+:10072000020089E2E80186E5140089E2EC0186E531
+:100730002C0089E2F00186E5120089E2F40186E5E9
+:10074000180089E2F80186E50A0089E2FC0186E5E5
+:100750000C0089E2000286E51A0089E2040286E5BF
+:100760001C0089E2080286E50E0089E20C0286E59B
+:10077000100089E2100286E5030089E2140286E592
+:10078000380089E2180286E5160089E21C0286E537
+:10079000010089E2200286E5401089E21E0089E21C
+:1007A0009011A6E59C0086E50A08A0E304068BE507
+:1007B0000507A0E30C068BE57D06A0E314068BE598
+:1007C0000A07A0E31C068BE50000A0E36F20A0E36E
+:1007D000B201C9E1B620C1E1B020D1E10228A0E117
+:1007E00004268BE5B220D1E10228A0E10C268BE59E
+:1007F000B420D1E10228A0E114268BE56F28A0E304
+:100800001C268BE50200C9E52C0089E5340089E54A
+:10081000300089E50300C9E50500C9E5BA01C9E171
+:10082000BE01C9E11420A0E3B002C9E10060A0E369
+:10083000BC21C9E10690A0E10000A0E3E01B10E5A7
+:100840000000A0E3E00B10E5011EB0E101A0A05301
+:10085000000EB0E10100005A01005AE30300000A53
+:1008600038019FE50500D0E5000050E3F1FFFF0AE5
+:1008700028B19FE500A0A0E3B4C1DBE10A00A0E13C
+:1008800000005CE30B0000DA10308DE201184AE250
+:100890000C2591E5000052E3FCFFFF0A102591E5CD
+:1008A00080E083E02228A0E1010080E20C0050E11A
+:1008B000B020CEE1F5FFFFBAE0009FE52C1090E5F7
+:1008C000011081E22C1080E50400D0E5000050E327
+:1008D000C8109F150000A0130400C1157700001A6E
+:1008E000D0009FE5022CA0E310108DE2B70100EBD1
+:1008F000A8B09FE5016086E234009BE5010080E23C
+:1009000034008BE5BC10DBE1BA00DBE100E041E044
+:1009100000005EE3100000DA10108DE2800081E03C
+:1009200001001EE3020040E2B210F011B2C0D0E1BB
+:100930000020A0E301408410CE10B0E10500000AC1
+:10094000B430F0E10C4084E0B2C0D0E1011051E2DB
+:10095000032082E0F9FFFF1A024084E03C009FE59B
+:10096000B011D0E1BE00D0E100B041E000005BE397
+:100970002D0000DA10108DE2800081E001001BE301
+:10098000020040E2B210F011B2C0D0E10020A0E3BA
+:1009900001508510CB10B0E11B0000EA40000100BF
+:1009A00000000100700401000000000000000000D1
+:1009B00022002222580001007000010053657020BF
+:1009C0003132203230313900F424080070756C73F4
+:1009D000652073746162696C697A6174696F6E20F5
+:1009E00076322E30203D3E2025730A636F6D70698C
+:1009F0006C65643A2025730A6265636175736520CE
+:100A000077652063616E2100700201000500000A15
+:100A1000B430F0E10C5085E0B2C0D0E1011051E2F9
+:100A2000032082E0F9FFFF1A025085E094001FE5E1
+:100A3000B811D0E1010056E12000003A9E0600E026
+:100A4000BF0400EB08008DE50190A0E10400A0E1E7
+:100A5000BB0400EB08209DE50930A0E13D0300EB5D
+:100A6000C8201FE5483082E2030083E89B0600E0CF
+:100A7000B30400EB0040A0E10160A0E10500A0E1AB
+:100A8000AF0400EB0630A0E10420A0E1310300EB4D
+:100A9000F8201FE50040A0E3503082E2030083E825
+:100AA000000082E2300090E5001082E2010080E266
+:100AB0000190A0E30450A0E10460A0E1300081E5D2
+:100AC0000000A0E3E00B10E5800CB0E10100A0E322
+:100AD0004700005A3CB11FE5010059E3BE01CBE1DC
+:100AE00054FFFF1A0090A0E338009BE50960A0E1E5
+:100AF000350600EB08208DE2030082E80300DBE509
+:100B00008F0400EB50308BE20C0093E8B10400EB53
+:100B100003008DE8B201DBE1890400EB48308BE291
+:100B20000C0093E8500500EB0C009DE86C0200EB14
+:100B300008308DE20C0093E8A60400EB1C0400EBE7
+:100B4000B611DBE1010050E1020000CA001061E2D1
+:100B5000010050E1000000AA0100A0E1080080E0CF
+:100B60000088A0E12888A0E17D0E48E27D0E50E3D8
+:100B70000800009A020B48E2BC11DBE1EE0F40E2F4
+:100B8000570100EB070080E00078A0E1EE8FA0E3C2
+:100B90002778A0E1028B88E2010A57E30800003AB7
+:100BA0000100A0E3B002CBE10000A0E3C01B10E510
+:100BB000011881E3C01B00E5017AA0E3017047E260
+:100BC000040000EA0000A0E3B002CBE1C01B10E586
+:100BD0000118C1E3C01B00E5FF08A0E30718A0E16E
+:100BE000FF0480E20C1680E50818A0E1141680E5E9
+:100BF00010FFFFEA5C721FE5010059E3BE01C7E187
+:100C00000B00001A0300D7E50090A0E34C0400EBB2
+:100C1000503087E20C0093E86E0400EB483087E226
+:100C20000C0093E80A0500EB0D0400EB0060A0E364
+:100C3000B201C7E107C0A0E1BA01DCE1B870D7E1B9
+:100C4000010050E35E00001AFF18A0E3FF1481E2E8
+:100C5000040691E52028A0E1C4021FE5B020C0E110
+:100C60000C2691E52228A0E1B220C0E1142691E5EE
+:100C70002228A0E1B420C0E11C1691E52118A0E1D2
+:100C8000B610C0E1B0B0D0E1520F8FE20C0090E896
+:100C9000F8021FE5501080E2030091E82B0400EBFE
+:100CA000010AA0330100403200005B310500002A38
+:100CB00001008BE2FF18A0E30008A0E1FF1481E22D
+:100CC000040681E53E0000EA110E8FE20C0090E878
+:100CD00038031FE5501080E2030091E8B40400EBF4
+:100CE0000700002A00005BE30500000A01004BE258
+:100CF000FF18A0E30008A0E1FF1481E2040681E5EB
+:100D00002F0000EA6CB31FE5D8008FE20C0090E8DA
+:100D100048108BE2030091E8A50400EB1100002AC3
+:100D20000100DBE5081040E20F0051E3100040C273
+:100D30000100CBC5FF08A0E33A10A0E3FF0480E266
+:100D4000081A80E5001A90E5020011E3FCFFFF0A93
+:100D50000110DBE5081A80E5001A90E5020011E3B6
+:100D6000FCFFFF0A160000EA80008FE20C0090E80A
+:100D700048108BE2030091E8F40300EB1000002A16
+:100D80000100DBE5081040E2700051E3100080B282
+:100D90000100CBB5FF08A0E33A10A0E3FF0480E216
+:100DA000081A80E5001A90E5020011E3FCFFFF0A33
+:100DB0000110DBE5081A80E5001A90E5020011E356
+:100DC000FCFFFF0AFF18A0E30708A0E1FF1481E27F
+:100DD0000C0681E597FEFFEA0000000000003E409F
+:100DE0000000000000005940000000000040AF403B
+:100DF0000000000000409F4010402DE9D3FDFFEBB4
+:100E00001040BDE80000A0E31EFF2FE10F502DE9C8
+:100E1000B4009FE5000090E5000050E30FE0A01152
+:100E200010FF2F110F50BDE804F05EE20F502DE9C6
+:100E300094009FE5080090E5000050E30FE0A0114A
+:100E400010FF2F110F50BDE804F05EE20F502DE9A6
+:100E500074009FE5040090E5000050E30FE0A0114E
+:100E600010FF2F110F50BDE804F05EE20F502DE986
+:100E700054009FE50C0090E5000050E30FE0A01146
+:100E800010FF2F110F50BDE804F05EE20F502DE966
+:100E900034009FE5100090E5000050E30FE0A01142
+:100EA00010FF2F110F50BDE804F05EE20F502DE946
+:100EB00014009FE5140090E5000050E30FE0A0113E
+:100EC00010FF2F110F50BDE804F05EE25800010042
+:100ED00001C08FE21CFF2FE10FB408491CB506AB1F
+:100EE0006A4679440090059800F01BFA0020694694
+:100EF00000F02CFA1CBC08BC04B0184767040000C2
+:100F0000F8B504000E00002030E0E168200000F099
+:100F1000E7FA00282CD0252802D06268A16821E0D9
+:100F2000E1680027200000F0DBFA050020D028004F
+:100F30004138192802D80127FF0220353200290044
+:100F400020002760FFF706F9002808D0012801D10A
+:100F5000361DDAE7F61DF608F6000836D5E76268B2
+:100F6000A168280000F0BDFA206A401C2062CCE78E
+:100F7000206AF8BC08BC184770B505000C00012AAF
+:100F800001D101200BE02868800600D5EA69002025
+:100F900000E0401C904202D2215C0029F9D1A969ED
+:100FA0002618091AA961296A091828002962C04669
+:100FB000C04605E020786A68A968641C00F091FAD0
+:100FC000B442F7D32800C046C04670BC08BC1847DE
+:100FD000030052E32A00009A03C010E20800000A4E
+:100FE0000130D1E402005CE30C2082E001C0D19426
+:100FF0000130C0E40130D13401C0C094042042E289
+:101000000130C034033011E2E100000A042052E252
+:101010001B00003A03C031E7020053E30800000A56
+:101020000F00008A2C34A0E104C0B1E5042052E294
+:101030000C3C83E1043080E4F9FFFF2A011081E2D7
+:101040000F0000EA2C38A0E104C0B1E5042052E210
+:101050000C3883E1043080E4F9FFFF2A021081E2BA
+:10106000070000EA2C3CA0E104C0B1E5042052E2F4
+:101070000C3483E1043080E4F9FFFF2A031081E29D
+:101080000000A0E1822FB0E10130D12401C0D124C1
+:101090000120D1440130C02401C0C0240120C0443B
+:1010A0001EFF2FE10020A0E3040051E30700003AF7
+:1010B00003C010E2D000000A04C06CE202005CE34E
+:1010C0000120C0140C1041E0B220C0A0CA0000EA08
+:1010D00081CFB0E10120C0240120C0240120C04400
+:1010E0001EFF2FE1013090E14C00004A0020B0E3E8
+:1010F000A03071E04300003A203271E03400003A41
+:10110000203471E02600003A203671E01700003AE2
+:10111000203871E00900003A0114A0E1203871E0A4
+:10112000FF2482E3FF2882230114A021203671E0EE
+:101130000E00003A003071E26F00002A2114A02155
+:10114000A03771E0810740200220B2E0203771E033
+:10115000010740200220B2E0A03671E08106402065
+:101160000220B2E0203671E0010640200220B2E009
+:10117000A03571E0810540200220B2E0203571E009
+:10118000010540200220B2E0A03471E0810440203B
+:101190000220B2E0203471E0010440200220B2E0DD
+:1011A000E5FFFF2AA03371E0810340200220B2E076
+:1011B000203371E0010340200220B2E0A03271E050
+:1011C000810240200220B2E0203271E00102402082
+:1011D0000220B2E0A03171E0810140200220B2E0A3
+:1011E000203171E0010140200220B2E0A03071E026
+:1011F000810040200220B2E0011050E00010A03138
+:101200000200A2E01EFF2FE1011050E00100A02328
+:101210001EFF2F210010A0E10000B0E31EFF2FE110
+:10122000022111E20010614240C032E00000602261
+:10123000203271E01D00003A203471E00F00003AC6
+:101240000113A0E1203471E03F2382E30B00003A58
+:101250000113A0E1203471E03F2682E30700003A49
+:101260000113A0E1203471E03F2982E30113A021A2
+:101270003F2C8223003071E21D00002A2113A0219F
+:10128000A03371E0810340200220B2E0203371E0FE
+:10129000010340200220B2E0A03271E08102402030
+:1012A0000220B2E0203271E0010240200220B2E0D0
+:1012B000A03171E0810140200220B2E0203171E0D4
+:1012C000010140200220B2E0EBFFFF2AA03071E0D4
+:1012D000810040200220B2E0011050E00010A03157
+:1012E0000200A2E0CCCFB0E1000060420010612219
+:1012F0001EFF2FE1CCCFB0E10000604201402DE99C
+:101300000000B0E30000A0E10240BDE81EFF2FE1B5
+:10131000704770477047000001694A1C02610878F5
+:10132000704710B590B00C00039200220692064A56
+:10133000059019007A4401A802940492FFF7E0FD99
+:1013400010B010BC08BC1847E1FFFFFF0A6810701E
+:10135000521C0A60704700002BC08FE21CFF2FE177
+:1013600010B54369002B02D0C046C04601E0FFF72C
+:1013700003FE10BC012008BC18471268010024318C
+:101380000A7000224A700122EAE711680022D24363
+:10139000E6E7000010402DE9202052E20500003A67
+:1013A0001850B1E8202052E21850A0E81850B1E8D7
+:1013B0001850A0E8F9FFFF2A02CEB0E11850B1287A
+:1013C0001850A0281800B1481800A0481040BDE8E7
+:1013D00002CFB0E104309124043080241EFF2F019D
+:1013E000822FB0E1B230D1200120D144B230C020F0
+:1013F0000120C0441EFF2FE10020A0E300402DE9A2
+:101400000230A0E102C0A0E102E0A0E1201051E220
+:101410000C50A0280C50A02820105122FBFFFF2ABE
+:10142000011EB0E10C50A0280C00A0480040BDE80F
+:101430000111B0E1042080241EFF2F01B220C04022
+:10144000010111E30120C0141EFF2FE10E50A0E1A5
+:10145000180000EB05E0A0E10050B0E10D10A0E1A4
+:101460000A30A0E10700C0E300D0A0E160D08DE227
+:1014700020402DE957FBFFEB2040BDE80060A0E3D2
+:101480000070A0E30080A0E300B0A0E30710C1E378
+:1014900005C0A0E1C009ACE8C009ACE8C009ACE8EF
+:1014A000C009ACE801D0A0E11EFF2FE10400C04656
+:1014B000C0462000FEF78AFE00009FE51EFF2FE1D8
+:1014C000700801000C109FE51800A0E3563412EFDD
+:1014D0001EFF2FE108000000260002001EFF2FE182
+:1014E00008471047030031E110402DE90231234243
+:1014F000E102004A024050E003E0D1E00300002A8C
+:10150000042092E00E30A3E0040050E00E10C1E091
+:1015100090C19FE5214AA0E123EA44E083001CE159
+:10152000840A3C113C00000A0C30C3E1041AC1E1FA
+:10153000013683E320C07EE21700003A320E90E0CD
+:10154000331EA1E0130C90E00010B1E2010651E35C
+:101550001B00002A041A81E01040BDE8122CB0E103
+:101560001EFF2F51010090E28220B0311EFF2F118B
+:10157000000050E30100C0130010A1028130A0E17F
+:10158000020673E31EFF2F310000A0E30612512272
+:1015900014119FE5021181431EFF2FE1010052E368
+:1015A0000320A3E020E04EE21FC07EE200C0A03393
+:1015B000330E9020041AA1E0210A54E1E5FFFF0A4E
+:1015C000041A41E0011681E2A110B0E1041A81E0A1
+:1015D0001040BDE86000B0E10700003A0000B0E252
+:1015E00012CCB0310400001AE0FFFFEA010090E2E3
+:1015F0008220B031E0FFFF1ADCFFFFEA8130A0E17A
+:10160000020673E31EFF2F310000A0E306125122F1
+:1016100094109FE5021181431EFF2FE1840A3CE1F3
+:101620000400000A1040BDE8AC0011E10211010203
+:101630000000A0031EFF2FE1010050E30140A1E0E4
+:10164000010052E303E0A3E00C0054E10C005E91C2
+:101650001040BDE854C09FE51600008A0000A0E1DC
+:10166000010050E30100A1E0010052E30320A3E0E8
+:10167000020050E10500000A020670E30000A0032A
+:101680001EFF2F010310A0E10000A0E31EFF2FE1C9
+:10169000030031E10000A0E31EFF2F510000A0E392
+:1016A0000C109FE51EFF2FE10000E0FF0000F07F1F
+:1016B000110000040000F87F04109FE50000A0E383
+:1016C0005F0300EA0000F87F04109FE50000A0E33C
+:1016D0005B0300EA0000F87F00402DE902E6A0E38A
+:1016E00081007EE10000500383007E9100005203E0
+:1016F0001400008A0040BDE80000A0E103C091E1B1
+:101700000400004A030051E1020050010800006A91
+:1017100000000FE11EFF2FE1010053E10000520124
+:1017200000000FE10902C0E30201803300F028E16C
+:101730001EFF2F7101C0A0E302005C3300005C6358
+:1017400000000FE11EFF2FE10040BDE80D081CE383
+:10175000D8FFFF0A570300EA70402DE940C49FE517
+:101760002142DCE12342DC115300000A035021E056
+:1017700021420CE0A54F84E123521CE00C02111120
+:101780003C00000A8115A0E18335A0E1A01A81E1A7
+:10179000A23A83E1054044E0FF4784E2021181E37D
+:1017A000023183E38005A0E18225A0E15D0000EB2A
+:1017B000806AB0E1A005A0E1443883E0810A80E1BD
+:1017C000A115A0E1032A81E0841F22E00A00000A9B
+:1017D00086E0B0E10361A0330700003A0030A013B7
+:1017E0000231A0030000B0E20010A1E2A30F10E15B
+:1017F0000161A0E3A30FC0E10361A013A4E39FE58F
+:10180000840F31E10C00004A0E0012E101E0DE110C
+:101810000900000A7040BDE81EFF2FE1845FB0E1BF
+:1018200002051E5301051E430161A0030361A013BD
+:10183000010090020010A1E2EFFFFFEA010354E370
+:101840007040BDD80000A0D3061281D2021101D28F
+:101850001EFF2FD114C086E37040BDE80000E0E316
+:10186000061241A2A01081E101C28CA3201621E042
+:101870000000A0E31EFF2FE10C0211E10000000AAE
+:10188000060000EA0C0213E12200000A0000A0E3B7
+:101890007040BDE8031021E0021101E21EFF2FE1BC
+:1018A0007040BDE80000E0E3031021E0A01081E1FA
+:1018B000201621E00000A0E31EFF2FE181E0A0E15F
+:1018C0008C025EE1000050038350A0E18C02559130
+:1018D0007040BDE8D0C29FE50000520375FFFF8A4B
+:1018E0000000A0E102C6A0E381007CE10500001A2F
+:1018F00083007CE10800000A033031E00211C1E3FB
+:10190000021181431EFF2FE1033021E00000A0E31C
+:10191000021103E21EFF2FE17040BDE80000A0E3CA
+:1019200088129FE51EFF2FE1E0402DE90050A0E165
+:1019300001E0A0E383C0A0E110002DE90140A0E197
+:101940002CCDA0E1561F8FE20CC191E70010A0E35F
+:101950009C6280E00060A0E39C03A1E0000090E0B6
+:101960000110A1E0000056E00110C6E0916CACE06F
+:101970000010A0E39C6280E00060A0E39C03A1E073
+:10198000000090E00110A1E0000056E00110C6E068
+:10199000916CACE00010A0E39C6580E09C04A1E0A9
+:1019A000926187E09360AEE00E7097E000E0A0E304
+:1019B0009371AEE000E0AEE2066096E00770B7E03B
+:1019C0000EE0AEE0006076E20770D5E00EE0C4E025
+:1019D0009C0EA1E09CE786E000E0A0E3060090E01A
+:1019E0000010A1E2926087E09271AEE09370AEE0E9
+:1019F000066096E00770B7E093E12EE00EE0AEE0FF
+:101A0000006076E20070F7E20EE0C5E09C6E87E0D1
+:101A100000E0A0E305CFA0E12551A0E1070090E0A0
+:101A20000010A1E2045F85E1A110B0E16000A0E137
+:101A3000926087E0006076E29271AEE09370AEE073
+:101A40000770DCE093E12EE00EE0C5E0025056E0C6
+:101A50000340D7E000E0DEE20560A0210470A02191
+:101A60000000B0E20010A1E2010056E3010057338C
+:101A70000000B0E00110A1E0020111E3F000BD1888
+:101A80000230A0130040BD181EFF2F110130A0E34B
+:101A9000F000BDE8000090E00040BDE80110A1E0CA
+:101AA0001EFF2FE1FCC00FFC830F3EF85F8D89F411
+:101AB000F0F0F0F0B50373EDEAA00EEA48B4C2E628
+:101AC000E3388EE31C3870E0A6C867DDA70D74DA32
+:101AD000E53594D7037BC7D4D2200DD2A87464CF48
+:101AE000CCCCCCCCE68745CA7C0CCEC77BC865C5C0
+:101AF000C3300CC3C0C0C0C00BFA82BE0B6452BC62
+:101B0000A28B2EBAE00217B8B6600BB6B4400BB485
+:101B1000C84216B2020B2CB05C414CAE849176AC3C
+:101B2000AAAAAAAA573FE8A839052FA702B57EA5F9
+:101B30003D0AD7A32BC337A2A0A0A0A0E765119FA1
+:101B40009DD8899D9CC0099CD9E7909A511A1F99EC
+:101B5000ED25B4976CDA4F964F09F294C4859A93A9
+:101B60009224499209BCFD90EE23B88F6D35788E92
+:101B700008CB3D8D8CC0088CFBF2D88A8940AE8999
+:101B8000888888885FAB67877D8A4B865308348551
+:101B900042082184976E1283822008820804028101
+:101BA000000000800000FF070000F07F1400000428
+:101BB0000000F87F8135A0E1412AB0E1A03A83E13D
+:101BC00003002DE9023183130800004A0E2D42E282
+:101BD0009E2072E2130000DAFF0052E33312A0D11C
+:101BE0000010A0C30100A0E108D08DE21EFF2FE18C
+:101BF000822AA0E10010A0E3A22AB0E10231C303CF
+:101C00000E2D42E29E2072E2060000BAFF0052E36F
+:101C1000331241D0000051E308D08DD20100A0D191
+:101C20001EFF2FD1FFFFFFEA0300BDE82CC09FE598
+:101C3000010050E30130A1E0020673E301C88C8388
+:101C4000A0FEFF8AC10FE031020120321EFF2F31BA
+:101C50000000A0E1C10FE0E1020120E21EFF2FE140
+:101C6000C80002048135A0E1412AB0E1A03A83E135
+:101C700003002DE9023183130800004A0E2D42E2D1
+:101C80009E2072E20B0000BAFF0052E33312A0D193
+:101C90000010A0C30100A0E108D08DE21EFF2FE1DB
+:101CA000012181E2010672E3020000AA0000A0E324
+:101CB00008D08DE21EFF2FE10300BDE824C09FE5A0
+:101CC000010050E30130A1E0020673E301C88C83F8
+:101CD0007CFEFF8AC10FE0311EFF2F310000A0E122
+:101CE000C10FE0E11EFF2FE1E8000204023110E223
+:101CF000001060120010A001013183E32108B0E15F
+:101D0000013483120118B0011EFF2F01FF0411E3FB
+:101D1000023583120114A0010F0211E30135831271
+:101D20000112A001030111E3023683120111B00177
+:101D3000013683428110A051810AA0E1C11583E0E0
+:101D40001EFF2FE10131A0E30010A0E1EAFFFFEA4E
+:101D500003C091E10E00004A01067CE301065C53DA
+:101D60000300004A030051E11EFF2F110200500141
+:101D70001EFF2FE10400007A010671E30106735390
+:101D80001100004A030051E11EFF2FE1010051E163
+:101D90001EFF2FE101067CE30500005A01065CE30B
+:101DA000F9FFFF5A010053E11EFF2F1100005201FD
+:101DB0001EFF2FE102C6A0E381007CE183007C319D
+:101DC0000100002A010053E11EFF2FE100C09FE542
+:101DD00040FEFFEA19001604C4C19FE570402DE9DA
+:101DE00021E2DCE123E2DC115600000A035021E08D
+:101DF00021E20CE0A5EF8EE123521CE00C02111150
+:101E00004800000A05E08EE08C12C1E18C32C3E18B
+:101E1000FFE74EE2011681E3013683E391428CE055
+:101E2000906385E0046096E00C50B5E091438CE04F
+:101E30000030ACE290128CE00320E0E30C6096E00E
+:101E400014C0A0E30450B5E00030B3E2010011E19A
+:101E500001608613020C53E300C0ACE220406CE248
+:101E60004E28A2E01314A0E11504A0E1351C81E185
+:101E7000360C80E11644B0E1025A81E08E1F25E065
+:101E80000900000A84C0B0E10341A0330600003A13
+:101E9000023183030000B0E20010A1E2A30F10E1C1
+:101EA0000141A0E3A30FC0E10341A013F4C09FE5EB
+:101EB000020115E30C00004A0C0015E101C0DC1121
+:101EC0000900000A7040BDE81EFF2FE18E4FB0E10F
+:101ED00002051C5301051C430141A0030341A0134B
+:101EE000010090020010A1E2EFFFFFEA01035EE3B0
+:101EF00013C084A37040BDE8061241A201C28CA3A6
+:101F0000030000AA0000A0E3061281E2021101E230
+:101F10001EFF2FE10000E0E3A01081E1201621E088
+:101F20000000A0E31EFF2FE18E1FA0E10000A0E350
+:101F30007040BDE81EFF2FE18E1FA0E10000A0E36E
+:101F40007040BDE81EFF2FE18150A0E18C0255E1F9
+:101F5000000050038360A0E18C0256917040BDE800
+:101F600044C09FE500005203D2FDFF8A0000A0E1BB
+:101F700002C6A0E381005CE183005C910500008A59
+:101F80000000A0E3031021E0021101E27F1481E3CD
+:101F90000F1681E31EFF2FE110109FE50000A0E364
+:101FA0001EFF2FE10000FF070000F07F1300000478
+:101FB0000000F87F01C093E10E00004A01067CE3B7
+:101FC00001065C530300004A010053E11EFF2F117C
+:101FD000000052011EFF2FE10400007A010673E3A6
+:101FE000010671531100004A010053E11EFF2FE169
+:101FF000030053E11EFF2FE101067CE30500005AB8
+:1020000001065CE3F9FFFF5A030051E11EFF2F11A7
+:10201000020050011EFF2FE102C6A0E383007CE115
+:1020200081007C310100002A030051E11EFF2FE1F5
+:10203000011023E0000022E0033021E0022020E034
+:1020400008C09FE5011023E0000022E0A1FDFFEAA7
+:1020500019001604030031E110402DE9021121E2BC
+:1020600023FDFF4A023123E2030000EA030031E1CD
+:1020700010402DE9023123421DFDFF4A024050E08D
+:1020800003E0D1E00400002A042092E002E12EE205
+:102090000E30A3E0040050E00E10C1E004C29FE542
+:1020A000214AA0E123EA44E083001CE1840A3C11B8
+:1020B0005900000A002072E2CC30C3E1041AC1E1E9
+:1020C000CC30E3E020C07EE21000003A320E90E017
+:1020D000531EA1E0130C90E00010B1E21500004A7D
+:1020E000041A81E01040BDE8122CB0E149C1A0E320
+:1020F0001EFF2F51010090E2020152131EFF2F110B
+:10210000000050E3011081020100C0131EFF2FE107
+:1021100002C092E00320A3E001C0A01320E04EE241
+:1021200082208CE11EC07EE22800009A530E90E0CF
+:102130000010D1E2E9FFFF5A01C08CE212CCB0E1FD
+:102140000000B0E00110A1E084EA81E0AEEAB0E175
+:102150000800009A041A81E01040BDE8AC0F90E03E
+:1021600002015C331EFF2F11000050E301108102B9
+:102170000100C0131EFF2FE11700002A021691E292
+:10218000000050031040BD081800000AA4E5A0E1BB
+:10219000024BC4E3024044E2000090E00110A1E0E1
+:1021A000010611E3014044E2FAFFFF0A8E1F81E0BD
+:1021B000000054E3041A81E01040BDE81EFF2FA187
+:1021C0000000A0E3061281E2021101E21EFF2FE1EE
+:1021D000041A81E01040BDE81EFF2FE1C110B0E1FC
+:1021E000041A81E01040BDE86000A0E1010000EAAF
+:1021F0000010A0E31EFF2FE112C0A0E38120B0E198
+:1022000000001001F9FFFF0A020652E31EFF2F2112
+:102210000000A0E3021101E21EFF2FE1840A3CE16D
+:102220000400000A1040BDE8AC0011E10010A0035A
+:102230000000A0031EFF2FE1010050E30140A1E0D8
+:10224000010052E303E0A3E00C0054E10C005E91B6
+:102250001040BDE850C09FE516FDFF8A0000A0E1D8
+:10226000010050E30100A1E0010052E30320A3E0DC
+:10227000020050E10500000A020670E30000A0031E
+:102280001EFF2F010000A0E3021123E21EFF2FE139
+:10229000030031E10000A0E31EFF2F410000A0E396
+:1022A00008109FE51EFF2FE10000E0FF1200000470
+:1022B0000000F87F010011E1212AA0E1063CA0E323
+:1022C000021AC1E101C88C43013083E2022BC2E350
+:1022D000022053E0FE20E043350052E3011681E383
+:1022E0002200008A1B00000A150052E31000003A89
+:1022F000202052E20600009A000050E3203062E203
+:102300003102A0E11123A0E10010A0E3012082131B
+:10231000190000EA003062E2202082E21113A0E1FD
+:10232000301281E11023A0E10100A0E10010A0E340
+:10233000110000EA203062E210002DE91043A0E114
+:102340001133A0E1300283E13112A0E10420A0E1C9
+:102350001000BDE8080000EA012690E10000A0E3BB
+:102360000010A0E30221A0E301208212020000EA93
+:102370000120A0E30010A0E30000A0E301081CE39B
+:1023800002118113020012E101C8CCE31EFF2F01EC
+:102390008220B0E10200003A0200000A010090E24F
+:1023A0000010A1E21EFF2FE14C2FB0E1FAFFFF4A1F
+:1023B000FBFFFF1A010090E20010A1E20100C0E360
+:1023C000F7FFFFEA1EFF2FE11EFF2FE102C580E2AB
+:1023D0007F041CE30500000AC011B0E1800EA0E1FB
+:1023E0000E1381E21EFF2F51071241E21EFF2FE163
+:1023F00002051CE30500000A0010A0E18000B0E126
+:102400001EFF2F010000A0E36010A0E11EFF2FE1DE
+:1024100014C09FE58024B0E10400001A0000A0E190
+:10242000071680E30200A0E11EFF2FE11800000460
+:1024300000009FE5020000EA0000C07F7847C04628
+:102440001EFF2FE10F300CE2090053E30800A00348
+:102450001800000A0A0053E30600000A080053E3CC
+:102460001EFF2F1140001C030500000A0000A0E31E
+:102470000010A0E31EFF2FE140001CE30201A013A7
+:102480001EFF2FE110001CE30400000A0F32C0E31E
+:10249000FF2400E2A31182E1830EA0E11EFF2FE1E1
+:1024A0000E0200E2FF24C1E3002082E1FF0401E20A
+:1024B000E20E80E11EFF2FE101061CE30A00000A84
+:1024C00007081CE30200000A8C17E0E18110B0E16C
+:1024D0001EFF2FE10302A0E300200FE10F22C2E361
+:1024E000002082E102F028E11EFF2FE10000A0E3BE
+:1024F0001EFF2FE16C6F636B5F5374616250756CEC
+:1025000073655F6932630000282508000000010040
+:10251000700000000001080098250800700001000C
+:10252000E00E000028010800000800000000000084
+:10253000000000000000000000000000000000009B
+:10254000000000000000000000000000010000008A
+:10255000000000000000000000000000000000007B
+:10256000000000000000000000000000000000006B
+:10257000000000000000000000000000000000005B
+:10258000000000000000000000000000000000004B
+:08259000000000000000000043
+:04000005000800BC33
+:00000001FF

+ 675 - 0
microcontroller/EOM_lock.htm

@@ -0,0 +1,675 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html><head>
+<title>Static Call Graph - [C:\Keil\ARM\Examples\EOM_lock\EOM_lock.axf]</title></head>
+<body><HR>
+<H1>Static Call Graph for image C:\Keil\ARM\Examples\EOM_lock\EOM_lock.axf</H1><HR>
+<BR><P>#&#060CALLGRAPH&#062# ARM Linker, RVCT4.0 [Build 524]: Last Updated: Thu Sep 12 13:09:05 2019
+<BR><P>
+<H3>Maximum Stack Usage =        704 bytes + Unknown(Functions without stacksize, Untraceable Function Pointers)</H3><H3>
+Call chain for Maximum Stack Depth:</H3>
+main &rArr; lock_StabPulse_i2c &rArr; __2sprintf &rArr; _printf_char_common &rArr; __printf
+<P>
+<H3>
+Functions with no stack information
+</H3><UL>
+ <LI><a href="#[2586d0]">Reset_Handler</a>
+ <LI><a href="#[25870c]">__user_initial_stackheap</a>
+</UL>
+</UL>
+<P>
+<H3>
+Function Pointers
+</H3><UL>
+ <LI><a href="#[2586d0]">Reset_Handler</a>
+ <LI><a href="#[258568]">Undef_Handler</a>
+ <LI><a href="#[2585a4]">SWI_Handler</a>
+ <LI><a href="#[2585e0]">PAbt_Handler</a>
+ <LI><a href="#[258694]">DAbt_Handler</a>
+ <LI><a href="#[25861c]">IRQ_Handler</a>
+ <LI><a href="#[258658]">FIQ_Handler</a>
+ <LI><a href="#[2539b4]">__main</a>
+ <LI><a href="#[256678]">main</a>
+ <LI><a href="#[251dd0]">_sputc</a>
+ <LI><a href="#[251f38]">_printf_input_char</a>
+ <LI><a href="#[24ce20]">__I$use$semihosting</a>
+</UL>
+<P>
+<H3>
+Global Symbols
+</H3>
+<P><STRONG><a name="[2586d0]"></a>Reset_Handler</STRONG> (ARM, 0 bytes, Stack size unknown bytes, aduc702x.o(Reset))
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[2539b4]"></a>__main</STRONG> (ARM, 8 bytes, Stack size 0 bytes, __main.o(!!!main))
+<BR><BR>[Calls]<UL><LI><a href="#[24a954]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__scatterload
+<LI><a href="#[2523ac]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_entry
+</UL>
+
+<P><STRONG><a name="[24a954]"></a>__scatterload</STRONG> (ARM, 0 bytes, Stack size unknown bytes, __scatter.o(!!!scatter))
+<BR><BR>[Called By]<UL><LI><a href="#[2539b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__main
+</UL>
+
+<P><STRONG><a name="[24a918]"></a>__scatterload_rt2</STRONG> (ARM, 52 bytes, Stack size unknown bytes, __scatter.o(!!!scatter), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[2523ac]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_entry
+</UL>
+
+<P><STRONG><a name="[24a8dc]"></a>__scatterload_null</STRONG> (ARM, 0 bytes, Stack size unknown bytes, __scatter.o(!!!scatter), UNUSED)
+
+<P><STRONG><a name="[24a738]"></a>__scatterload_copy</STRONG> (ARM, 40 bytes, Stack size unknown bytes, __scatter_copy.o(!!handler_copy), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[24a738]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__scatterload_copy
+</UL>
+<BR>[Called By]<UL><LI><a href="#[24a738]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__scatterload_copy
+</UL>
+
+<P><STRONG><a name="[24a648]"></a>__scatterload_zeroinit</STRONG> (ARM, 44 bytes, Stack size unknown bytes, __scatter_zi.o(!!handler_zi), UNUSED)
+
+<P><STRONG><a name="[254b0c]"></a>_printf_percent</STRONG> (ARM, 0 bytes, Stack size unknown bytes, _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000))
+<BR><BR>[Called By]<UL><LI><a href="#[25573c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__printf (via Veneer)
+</UL>
+
+<P><STRONG><a name="[254bfc]"></a>_printf_s</STRONG> (ARM, 0 bytes, Stack size unknown bytes, _printf_s.o(.ARM.Collect$$_printf_percent$$00000014))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24 + Unknown Stack Size
+<LI>Call Chain = _printf_s &rArr; _printf_string &rArr; _printf_cs_common &rArr; _printf_str
+</UL>
+<BR>[Calls]<UL><LI><a href="#[251c68]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_string (via Veneer)
+</UL>
+
+<P><STRONG><a name="[251b78]"></a>_printf_percent_end</STRONG> (ARM, 0 bytes, Stack size unknown bytes, _printf_percent_end.o(.ARM.Collect$$_printf_percent$$00000017))
+
+<P><STRONG><a name="[24fd3c]"></a>__rt_lib_init</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit.o(.ARM.Collect$$libinit$$00000000))
+<BR><BR>[Calls]<UL><LI><a href="#[24d7bc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_fp_init (via Veneer)
+</UL>
+<BR>[Called By]<UL><LI><a href="#[250e94]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_entry_li (via Veneer)
+</UL>
+
+<P><STRONG><a name="[24de88]"></a>__rt_lib_init_alloca_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000002A))
+
+<P><STRONG><a name="[24df00]"></a>__rt_lib_init_argv_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000028))
+
+<P><STRONG><a name="[24e2c0]"></a>__rt_lib_init_atexit_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000017))
+
+<P><STRONG><a name="[24e158]"></a>__rt_lib_init_clock_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000001D))
+
+<P><STRONG><a name="[24dd98]"></a>__rt_lib_init_cpp_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000002E))
+
+<P><STRONG><a name="[24de10]"></a>__rt_lib_init_exceptions_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000002C))
+
+<P><STRONG><a name="[24e1d0]"></a>__rt_lib_init_fp_trap_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000001B))
+
+<P><STRONG><a name="[24e0e0]"></a>__rt_lib_init_getenv_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000001F))
+
+<P><STRONG><a name="[24e6bc]"></a>__rt_lib_init_heap_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000006))
+
+<P><STRONG><a name="[24e518]"></a>__rt_lib_init_lc_collate_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000000D))
+
+<P><STRONG><a name="[24e4a0]"></a>__rt_lib_init_lc_ctype_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000000F))
+
+<P><STRONG><a name="[24e428]"></a>__rt_lib_init_lc_monetary_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000011))
+
+<P><STRONG><a name="[24e3b0]"></a>__rt_lib_init_lc_numeric_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000013))
+
+<P><STRONG><a name="[24e338]"></a>__rt_lib_init_lc_time_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000015))
+
+<P><STRONG><a name="[24e5cc]"></a>__rt_lib_init_rand_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000000A))
+
+<P><STRONG><a name="[24dd5c]"></a>__rt_lib_init_return</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$0000002F))
+
+<P><STRONG><a name="[24e248]"></a>__rt_lib_init_signal_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000019))
+
+<P><STRONG><a name="[24e068]"></a>__rt_lib_init_stdio_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000021))
+
+<P><STRONG><a name="[24e644]"></a>__rt_lib_init_user_alloc_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libinit2.o(.ARM.Collect$$libinit$$00000008))
+
+<P><STRONG><a name="[24c1f0]"></a>__rt_lib_shutdown</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown.o(.ARM.Collect$$libshutdown$$00000000))
+<BR><BR>[Called By]<UL><LI><a href="#[24d4b0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_exit_ls (via Veneer)
+</UL>
+
+<P><STRONG><a name="[24aeb8]"></a>__rt_lib_shutdown_fp_trap_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$00000006))
+
+<P><STRONG><a name="[24acd8]"></a>__rt_lib_shutdown_heap_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$0000000E))
+
+<P><STRONG><a name="[24ac9c]"></a>__rt_lib_shutdown_return</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$0000000F))
+
+<P><STRONG><a name="[24ae04]"></a>__rt_lib_shutdown_signal_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$00000009))
+
+<P><STRONG><a name="[24af6c]"></a>__rt_lib_shutdown_stdio_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$00000003))
+
+<P><STRONG><a name="[24ad8c]"></a>__rt_lib_shutdown_user_alloc_1</STRONG> (Thumb, 0 bytes, Stack size unknown bytes, libshutdown2.o(.ARM.Collect$$libshutdown$$0000000B))
+
+<P><STRONG><a name="[2523ac]"></a>__rt_entry</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry.o(.ARM.Collect$$rtentry$$00000000))
+<BR><BR>[Called By]<UL><LI><a href="#[24a918]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__scatterload_rt2
+<LI><a href="#[2539b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__main
+</UL>
+
+<P><STRONG><a name="[250f48]"></a>__rt_entry_presh_1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry2.o(.ARM.Collect$$rtentry$$00000002))
+
+<P><STRONG><a name="[250bc4]"></a>__rt_entry_sh</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry4.o(.ARM.Collect$$rtentry$$00000004))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8 + Unknown Stack Size
+<LI>Call Chain = __rt_entry_sh &rArr; __user_setup_stackheap
+</UL>
+<BR>[Calls]<UL><LI><a href="#[250534]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__user_setup_stackheap
+</UL>
+
+<P><STRONG><a name="[250e94]"></a>__rt_entry_li</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry2.o(.ARM.Collect$$rtentry$$0000000A))
+<BR><BR>[Calls]<UL><LI><a href="#[24fd3c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_lib_init (via Veneer)
+</UL>
+
+<P><STRONG><a name="[250ed0]"></a>__rt_entry_postsh_1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry2.o(.ARM.Collect$$rtentry$$00000009))
+
+<P><STRONG><a name="[250de0]"></a>__rt_entry_main</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry2.o(.ARM.Collect$$rtentry$$0000000D))
+<BR><BR>[Calls]<UL><LI><a href="#[2503cc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;exit (via BX)
+</UL>
+
+<P><STRONG><a name="[250e1c]"></a>__rt_entry_postli_1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtentry2.o(.ARM.Collect$$rtentry$$0000000C))
+
+<P><STRONG><a name="[24f5bc]"></a>__rt_exit</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtexit.o(.ARM.Collect$$rtexit$$00000000))
+<BR><BR>[Called By]<UL><LI><a href="#[2503cc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;exit (via Veneer)
+</UL>
+
+<P><STRONG><a name="[24d4b0]"></a>__rt_exit_ls</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtexit2.o(.ARM.Collect$$rtexit$$00000003))
+<BR><BR>[Calls]<UL><LI><a href="#[24c1f0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_lib_shutdown (via Veneer)
+</UL>
+
+<P><STRONG><a name="[24d4ec]"></a>__rt_exit_prels_1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtexit2.o(.ARM.Collect$$rtexit$$00000002))
+
+<P><STRONG><a name="[24d474]"></a>__rt_exit_exit</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rtexit2.o(.ARM.Collect$$rtexit$$00000004))
+<BR><BR>[Calls]<UL><LI><a href="#[24d6cc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_sys_exit
+</UL>
+
+<P><STRONG><a name="[25870c]"></a>__user_initial_stackheap</STRONG> (ARM, 0 bytes, Stack size unknown bytes, aduc702x.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[250534]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__user_setup_stackheap
+</UL>
+
+<P><STRONG><a name="[256984]"></a>delay</STRONG> (ARM, 4 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[256948]"></a>ADCtoDAT</STRONG> (ARM, 12 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[25690c]"></a>DATtoADC</STRONG> (ARM, 8 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[2568d0]"></a>DATtoDAC</STRONG> (ARM, 8 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[256894]"></a>Read_Digital</STRONG> (ARM, 24 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[256858]"></a>Write_Digital</STRONG> (ARM, 40 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[25681c]"></a>ADCpoweron</STRONG> (ARM, 20 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[2567e0]"></a>get_DACs</STRONG> (ARM, 64 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[2567a4]"></a>set_DACs</STRONG> (ARM, 64 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[256768]"></a>set_pga</STRONG> (ARM, 56 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[25672c]"></a>get_pga</STRONG> (ARM, 84 bytes, Stack size 0 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[2566f0]"></a>My_IRQ_Handler</STRONG> (ARM, 472 bytes, Stack size 8 bytes, demo.o(.text), UNUSED)
+
+<P><STRONG><a name="[2566b4]"></a>lock_StabPulse_i2c</STRONG> (ARM, 2216 bytes, Stack size 568 bytes, demo.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 696 + Unknown Stack Size
+<LI>Call Chain = lock_StabPulse_i2c &rArr; __2sprintf &rArr; _printf_char_common &rArr; __printf
+</UL>
+<BR>[Calls]<UL><LI><a href="#[252550]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_f2d
+<LI><a href="#[25267c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_cdrcmple
+<LI><a href="#[2527e4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dmul
+<LI><a href="#[25294c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_cdcmple
+<LI><a href="#[252a78]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ui2d
+<LI><a href="#[252d84]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2uiz
+<LI><a href="#[253018]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_d2iz
+<LI><a href="#[253270]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_ddiv
+<LI><a href="#[2535b8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dsub
+<LI><a href="#[253630]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_drsub
+<LI><a href="#[2536e4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_dadd
+<LI><a href="#[2544b8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_idivmod
+<LI><a href="#[25483c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_memclr
+<LI><a href="#[2549e0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_memcpy
+<LI><a href="#[25591c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__2sprintf (via Veneer)
+</UL>
+<BR>[Called By]<UL><LI><a href="#[256678]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;main
+</UL>
+
+<P><STRONG><a name="[256678]"></a>main</STRONG> (ARM, 20 bytes, Stack size 8 bytes, demo.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 704 + Unknown Stack Size
+<LI>Call Chain = main &rArr; lock_StabPulse_i2c &rArr; __2sprintf &rArr; _printf_char_common &rArr; __printf
+</UL>
+<BR>[Calls]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> rtentry2.o(.ARM.Collect$$rtentry$$0000000D)
+</UL>
+<P><STRONG><a name="[25861c]"></a>IRQ_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = IRQ_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[258658]"></a>FIQ_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = FIQ_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[2585a4]"></a>SWI_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = SWI_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[258568]"></a>Undef_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = Undef_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[2585e0]"></a>PAbt_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = PAbt_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[258694]"></a>DAbt_Handler</STRONG> (ARM, 32 bytes, Stack size 24 bytes, irq_arm.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = DAbt_Handler
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> aduc702x.o(Reset)
+</UL>
+<P><STRONG><a name="[25591c]"></a>__2sprintf</STRONG> (Thumb, 36 bytes, Stack size 32 bytes, noretval__2sprintf.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 128 + Unknown Stack Size
+<LI>Call Chain = __2sprintf &rArr; _printf_char_common &rArr; __printf
+</UL>
+<BR>[Calls]<UL><LI><a href="#[251dd0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_sputc
+<LI><a href="#[251efc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_char_common
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c (via Veneer)
+</UL>
+
+<P><STRONG><a name="[25573c]"></a>__printf</STRONG> (Thumb, 120 bytes, Stack size 24 bytes, __printf.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24 + Unknown Stack Size
+<LI>Call Chain = __printf
+</UL>
+<BR>[Calls]<UL><LI><a href="#[254b0c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_percent (via Veneer)
+<LI><a href="#[2556c4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__ARM_common_call_via_r2
+<LI><a href="#[255700]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__ARM_common_call_via_r1
+</UL>
+<BR>[Called By]<UL><LI><a href="#[251efc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_char_common
+</UL>
+
+<P><STRONG><a name="[2555d4]"></a>_printf_str</STRONG> (Thumb, 88 bytes, Stack size 16 bytes, _printf_str.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 16<LI>Call Chain = _printf_str
+</UL>
+<BR>[Calls]<UL><LI><a href="#[255520]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_pre_padding (Weak Reference)
+<LI><a href="#[25555c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_post_padding (Weak Reference)
+<LI><a href="#[2556c4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__ARM_common_call_via_r2
+</UL>
+<BR>[Called By]<UL><LI><a href="#[251ce0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_cs_common
+</UL>
+
+<P><STRONG><a name="[2549e0]"></a>__aeabi_memcpy</STRONG> (ARM, 0 bytes, Stack size 0 bytes, rt_memcpy.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[2549a4]"></a>__rt_memcpy</STRONG> (ARM, 212 bytes, Stack size 0 bytes, rt_memcpy.o(.text), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251a88]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_memcpy4
+</UL>
+
+<P><STRONG><a name="[254968]"></a>_memcpy_lastbytes</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rt_memcpy.o(.text), UNUSED)
+
+<P><STRONG><a name="[25483c]"></a>__aeabi_memclr</STRONG> (ARM, 0 bytes, Stack size 0 bytes, rt_memclr.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[254800]"></a>__rt_memclr</STRONG> (ARM, 64 bytes, Stack size 0 bytes, rt_memclr.o(.text), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251830]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_memset_w
+</UL>
+
+<P><STRONG><a name="[2547c4]"></a>_memset</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rt_memclr.o(.text), UNUSED)
+
+<P><STRONG><a name="[2544f4]"></a>__aeabi_idiv</STRONG> (ARM, 0 bytes, Stack size 8 bytes, aeabi_sdivfast.o(.text), UNUSED)
+
+<P><STRONG><a name="[2544b8]"></a>__aeabi_idivmod</STRONG> (ARM, 556 bytes, Stack size 8 bytes, aeabi_sdivfast.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_idivmod
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[253b1c]"></a>__use_two_region_memory</STRONG> (Thumb, 2 bytes, Stack size 0 bytes, heapauxi.o(.text), UNUSED)
+
+<P><STRONG><a name="[253ae0]"></a>__rt_heap_escrow$2region</STRONG> (Thumb, 2 bytes, Stack size 0 bytes, heapauxi.o(.text), UNUSED)
+
+<P><STRONG><a name="[253aa4]"></a>__rt_heap_expand$2region</STRONG> (Thumb, 2 bytes, Stack size 0 bytes, heapauxi.o(.text), UNUSED)
+
+<P><STRONG><a name="[251efc]"></a>_printf_char_common</STRONG> (Thumb, 38 bytes, Stack size 72 bytes, _printf_char_common.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 96 + Unknown Stack Size
+<LI>Call Chain = _printf_char_common &rArr; __printf
+</UL>
+<BR>[Calls]<UL><LI><a href="#[25573c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__printf
+</UL>
+<BR>[Called By]<UL><LI><a href="#[25591c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__2sprintf
+</UL>
+
+<P><STRONG><a name="[251dd0]"></a>_sputc</STRONG> (Thumb, 10 bytes, Stack size 0 bytes, _sputc.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[25591c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__2sprintf
+</UL>
+<BR>[Address Reference Count : 1]<UL><LI> noretval__2sprintf.o(.text)
+</UL>
+<P><STRONG><a name="[251ce0]"></a>_printf_cs_common</STRONG> (Thumb, 26 bytes, Stack size 8 bytes, _printf_char.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = _printf_cs_common &rArr; _printf_str
+</UL>
+<BR>[Calls]<UL><LI><a href="#[251c2c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_mbtowc (Weak Reference)
+<LI><a href="#[2555d4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_str
+</UL>
+<BR>[Called By]<UL><LI><a href="#[251c68]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_string
+<LI><a href="#[251ca4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_char
+</UL>
+
+<P><STRONG><a name="[251ca4]"></a>_printf_char</STRONG> (Thumb, 16 bytes, Stack size 0 bytes, _printf_char.o(.text), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251ce0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_cs_common
+</UL>
+
+<P><STRONG><a name="[251c68]"></a>_printf_string</STRONG> (Thumb, 8 bytes, Stack size 0 bytes, _printf_char.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 24<LI>Call Chain = _printf_string &rArr; _printf_cs_common &rArr; _printf_str
+</UL>
+<BR>[Calls]<UL><LI><a href="#[251ce0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_cs_common
+</UL>
+<BR>[Called By]<UL><LI><a href="#[254bfc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_s (via Veneer)
+</UL>
+
+<P><STRONG><a name="[251a88]"></a>__aeabi_memcpy4</STRONG> (ARM, 0 bytes, Stack size 8 bytes, rt_memcpy_w.o(.text), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[2549a4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_memcpy
+</UL>
+
+<P><STRONG><a name="[251a4c]"></a>__aeabi_memcpy8</STRONG> (ARM, 0 bytes, Stack size 8 bytes, rt_memcpy_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[251a10]"></a>__rt_memcpy_w</STRONG> (ARM, 100 bytes, Stack size 8 bytes, rt_memcpy_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[2519d4]"></a>_memcpy_lastbytes_aligned</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rt_memcpy_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[2518e4]"></a>__aeabi_memclr4</STRONG> (ARM, 0 bytes, Stack size 4 bytes, rt_memclr_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[2518a8]"></a>__aeabi_memclr8</STRONG> (ARM, 0 bytes, Stack size 4 bytes, rt_memclr_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[25186c]"></a>__rt_memclr_w</STRONG> (ARM, 84 bytes, Stack size 4 bytes, rt_memclr_w.o(.text), UNUSED)
+
+<P><STRONG><a name="[251830]"></a>_memset_w</STRONG> (ARM, 0 bytes, Stack size unknown bytes, rt_memclr_w.o(.text), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[254800]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_memclr
+</UL>
+
+<P><STRONG><a name="[250534]"></a>__user_setup_stackheap</STRONG> (ARM, 96 bytes, Stack size 8 bytes, sys_stackheap_outer.o(.text))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8 + Unknown Stack Size
+<LI>Call Chain = __user_setup_stackheap
+</UL>
+<BR>[Calls]<UL><LI><a href="#[24f6ac]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__user_perproc_libspace
+<LI><a href="#[25870c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__user_initial_stackheap
+</UL>
+<BR>[Called By]<UL><LI><a href="#[250bc4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_entry_sh
+</UL>
+
+<P><STRONG><a name="[2503cc]"></a>exit</STRONG> (Thumb, 12 bytes, Stack size 0 bytes, exit.o(.text))
+<BR><BR>[Calls]<UL><LI><a href="#[24f5bc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_exit (via Veneer)
+<LI><a href="#[250354]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_call_atexit_fns (Weak Reference)
+</UL>
+<BR>[Called By]<UL><LI><a href="#[250de0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_entry_main
+</UL>
+
+<P><STRONG><a name="[24f6e8]"></a>__user_libspace</STRONG> (ARM, 12 bytes, Stack size 0 bytes, libspace.o(.text), UNUSED)
+
+<P><STRONG><a name="[24f6ac]"></a>__user_perproc_libspace</STRONG> (ARM, 0 bytes, Stack size 0 bytes, libspace.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[250534]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__user_setup_stackheap
+</UL>
+
+<P><STRONG><a name="[24f670]"></a>__user_perthread_libspace</STRONG> (ARM, 0 bytes, Stack size 0 bytes, libspace.o(.text), UNUSED)
+
+<P><STRONG><a name="[24d6cc]"></a>_sys_exit</STRONG> (ARM, 20 bytes, Stack size 0 bytes, sys_exit.o(.text))
+<BR><BR>[Called By]<UL><LI><a href="#[24d474]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_exit_exit
+</UL>
+
+<P><STRONG><a name="[24ce20]"></a>__I$use$semihosting</STRONG> (ARM, 0 bytes, Stack size 0 bytes, use_no_semi.o(.text))
+<BR>[Address Reference Count : 1]<UL><LI> sys_exit.o(.text)
+</UL>
+<P><STRONG><a name="[24cde4]"></a>__use_no_semihosting_swi</STRONG> (ARM, 4 bytes, Stack size 0 bytes, use_no_semi.o(.text), UNUSED)
+
+<P><STRONG><a name="[255700]"></a>__ARM_common_call_via_r1</STRONG> (Thumb, 2 bytes, Stack size 0 bytes, __printf.o(i.__ARM_common_call_via_r1))
+<BR><BR>[Called By]<UL><LI><a href="#[25573c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__printf
+</UL>
+
+<P><STRONG><a name="[2556c4]"></a>__ARM_common_call_via_r2</STRONG> (Thumb, 2 bytes, Stack size 0 bytes, __printf.o(i.__ARM_common_call_via_r2))
+<BR><BR>[Called By]<UL><LI><a href="#[2555d4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_str
+<LI><a href="#[25573c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__printf
+</UL>
+
+<P><STRONG><a name="[2536e4]"></a>__aeabi_dadd</STRONG> (ARM, 0 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$dadd))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_dadd
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[2536a8]"></a>_dadd</STRONG> (ARM, 452 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$dadd), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+<LI><a href="#[253720]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dsub1
+</UL>
+
+<P><STRONG><a name="[25366c]"></a>__fpl_inf_dadd</STRONG> (ARM, 0 bytes, Stack size unknown bytes, daddsub_noclz.o(x$fpl$dadd), UNUSED)
+
+<P><STRONG><a name="[251740]"></a>__fpl_dcheck_NaN2</STRONG> (ARM, 12 bytes, Stack size 0 bytes, dcheck.o(x$fpl$dcheck), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[250714]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_return_NaN
+</UL>
+<BR>[Called By]<UL><LI><a href="#[251524]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcmp_InfNaN
+<LI><a href="#[2527a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dmul
+<LI><a href="#[253234]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_ddiv
+<LI><a href="#[25357c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dsub
+<LI><a href="#[2536a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dadd
+</UL>
+
+<P><STRONG><a name="[251614]"></a>__fpl_dcheck_NaN1</STRONG> (ARM, 12 bytes, Stack size 0 bytes, dcheck1.o(x$fpl$dcheck1), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[250714]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_return_NaN
+</UL>
+<BR>[Called By]<UL><LI><a href="#[252d48]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dfixu
+<LI><a href="#[252fdc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dfix
+</UL>
+
+<P><STRONG><a name="[251524]"></a>__fpl_dcmp_InfNaN</STRONG> (ARM, 128 bytes, Stack size 4 bytes, dcmpin.o(x$fpl$dcmpinfnan), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[250624]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_cmpreturn
+<LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+<BR>[Called By]<UL><LI><a href="#[252640]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_drcmple
+<LI><a href="#[252910]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dcmple
+</UL>
+
+<P><STRONG><a name="[2514e8]"></a>__fpl_inf_dcmp</STRONG> (ARM, 0 bytes, Stack size unknown bytes, dcmpin.o(x$fpl$dcmpinfnan), UNUSED)
+
+<P><STRONG><a name="[253270]"></a>__aeabi_ddiv</STRONG> (ARM, 0 bytes, Stack size 16 bytes, ddiv.o(x$fpl$ddiv))
+<BR><BR>[Stack]<UL><LI>Max Depth = 16<LI>Call Chain = __aeabi_ddiv
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[253234]"></a>_ddiv</STRONG> (ARM, 464 bytes, Stack size 16 bytes, ddiv.o(x$fpl$ddiv), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+<LI><a href="#[2531bc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_ddiv_mantissas
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+
+<P><STRONG><a name="[2531f8]"></a>__fpl_inf_ddiv</STRONG> (ARM, 0 bytes, Stack size unknown bytes, ddiv.o(x$fpl$ddiv), UNUSED)
+
+<P><STRONG><a name="[2531bc]"></a>_ddiv_mantissas</STRONG> (ARM, 380 bytes, Stack size 20 bytes, ddiv.o(x$fpl$ddiv), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[253234]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_ddiv
+</UL>
+
+<P><STRONG><a name="[253018]"></a>__aeabi_d2iz</STRONG> (ARM, 0 bytes, Stack size 8 bytes, dfix.o(x$fpl$dfix))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_d2iz
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252fdc]"></a>_dfix</STRONG> (ARM, 172 bytes, Stack size 8 bytes, dfix.o(x$fpl$dfix), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251614]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN1
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+
+<P><STRONG><a name="[252fa0]"></a>__fpl_inf_dfix</STRONG> (ARM, 0 bytes, Stack size unknown bytes, dfix.o(x$fpl$dfix), UNUSED)
+
+<P><STRONG><a name="[252d84]"></a>__aeabi_d2uiz</STRONG> (ARM, 0 bytes, Stack size 8 bytes, dfixu.o(x$fpl$dfixu))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_d2uiz
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252d48]"></a>_dfixu</STRONG> (ARM, 132 bytes, Stack size 8 bytes, dfixu.o(x$fpl$dfixu), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251614]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN1
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+
+<P><STRONG><a name="[252d0c]"></a>__fpl_inf_dfixu</STRONG> (ARM, 0 bytes, Stack size unknown bytes, dfixu.o(x$fpl$dfixu), UNUSED)
+
+<P><STRONG><a name="[252b2c]"></a>__aeabi_i2d</STRONG> (ARM, 0 bytes, Stack size 0 bytes, dflt_noclz.o(x$fpl$dflt), UNUSED)
+
+<P><STRONG><a name="[252af0]"></a>_dflt</STRONG> (ARM, 88 bytes, Stack size 0 bytes, dflt_noclz.o(x$fpl$dflt), UNUSED)
+
+<P><STRONG><a name="[252ab4]"></a>__dflt_normalise</STRONG> (ARM, 0 bytes, Stack size unknown bytes, dflt_noclz.o(x$fpl$dflt), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[252a3c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dfltu
+</UL>
+
+<P><STRONG><a name="[252a78]"></a>__aeabi_ui2d</STRONG> (ARM, 0 bytes, Stack size 0 bytes, dflt_noclz.o(x$fpl$dfltu))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252a3c]"></a>_dfltu</STRONG> (ARM, 12 bytes, Stack size 0 bytes, dflt_noclz.o(x$fpl$dfltu), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[252ab4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__dflt_normalise
+</UL>
+
+<P><STRONG><a name="[25294c]"></a>__aeabi_cdcmple</STRONG> (ARM, 0 bytes, Stack size 0 bytes, dleqf.o(x$fpl$dleqf))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252910]"></a>_dcmple</STRONG> (ARM, 132 bytes, Stack size 0 bytes, dleqf.o(x$fpl$dleqf), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251524]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcmp_InfNaN
+</UL>
+
+<P><STRONG><a name="[2527e4]"></a>__aeabi_dmul</STRONG> (ARM, 0 bytes, Stack size 16 bytes, dmul.o(x$fpl$dmul))
+<BR><BR>[Stack]<UL><LI>Max Depth = 16<LI>Call Chain = __aeabi_dmul
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[2527a8]"></a>_dmul</STRONG> (ARM, 460 bytes, Stack size 16 bytes, dmul.o(x$fpl$dmul), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+
+<P><STRONG><a name="[25276c]"></a>__fpl_inf_dmul</STRONG> (ARM, 0 bytes, Stack size unknown bytes, dmul.o(x$fpl$dmul), UNUSED)
+
+<P><STRONG><a name="[25267c]"></a>__aeabi_cdrcmple</STRONG> (ARM, 0 bytes, Stack size 0 bytes, drleqf.o(x$fpl$drleqf))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252640]"></a>_drcmple</STRONG> (ARM, 156 bytes, Stack size 0 bytes, drleqf.o(x$fpl$drleqf), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251524]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcmp_InfNaN
+</UL>
+
+<P><STRONG><a name="[253630]"></a>__aeabi_drsub</STRONG> (ARM, 0 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$drsb))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_drsub
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[2535f4]"></a>_drsb</STRONG> (ARM, 24 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$drsb), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[253720]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dsub1
+<LI><a href="#[25375c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dadd1
+</UL>
+
+<P><STRONG><a name="[2535b8]"></a>__aeabi_dsub</STRONG> (ARM, 0 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$dsub))
+<BR><BR>[Stack]<UL><LI>Max Depth = 8<LI>Call Chain = __aeabi_dsub
+</UL>
+<BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[25357c]"></a>_dsub</STRONG> (ARM, 572 bytes, Stack size 8 bytes, daddsub_noclz.o(x$fpl$dsub), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+<LI><a href="#[25375c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dadd1
+</UL>
+
+<P><STRONG><a name="[253540]"></a>__fpl_inf_dsub</STRONG> (ARM, 0 bytes, Stack size unknown bytes, daddsub_noclz.o(x$fpl$dsub), UNUSED)
+
+<P><STRONG><a name="[2513bc]"></a>__dunder</STRONG> (ARM, 276 bytes, Stack size 4 bytes, dunder.o(x$fpl$dunder), UNUSED)
+
+<P><STRONG><a name="[251380]"></a>__dunder_d</STRONG> (ARM, 4 bytes, Stack size 0 bytes, dunder.o(x$fpl$dunder), UNUSED)
+
+<P><STRONG><a name="[252550]"></a>__aeabi_f2d</STRONG> (ARM, 0 bytes, Stack size 0 bytes, f2d.o(x$fpl$f2d))
+<BR><BR>[Called By]<UL><LI><a href="#[2566b4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;lock_StabPulse_i2c
+</UL>
+
+<P><STRONG><a name="[252514]"></a>_f2d</STRONG> (ARM, 96 bytes, Stack size 0 bytes, f2d.o(x$fpl$f2d), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[251290]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_fcheck_NaN1
+<LI><a href="#[253414]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_infinity (Weak Reference)
+</UL>
+
+<P><STRONG><a name="[2524d8]"></a>__fpl_inf_f2d</STRONG> (ARM, 0 bytes, Stack size unknown bytes, f2d.o(x$fpl$f2d), UNUSED)
+
+<P><STRONG><a name="[251290]"></a>__fpl_fcheck_NaN1</STRONG> (ARM, 8 bytes, Stack size 0 bytes, fcheck1.o(x$fpl$fcheck1), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[250714]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_return_NaN
+</UL>
+<BR>[Called By]<UL><LI><a href="#[252514]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_f2d
+</UL>
+
+<P><STRONG><a name="[24d7f8]"></a>__fplib_config_pureend_doubles</STRONG> (ARM, 0 bytes, Stack size 0 bytes, fpinit.o(x$fpl$fpinit), UNUSED)
+
+<P><STRONG><a name="[24d7bc]"></a>_fp_init</STRONG> (ARM, 4 bytes, Stack size 0 bytes, fpinit.o(x$fpl$fpinit))
+<BR><BR>[Called By]<UL><LI><a href="#[24fd3c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__rt_lib_init (via Veneer)
+</UL>
+
+<P><STRONG><a name="[250714]"></a>__fpl_return_NaN</STRONG> (ARM, 116 bytes, Stack size 0 bytes, retnan.o(x$fpl$retnan), UNUSED)
+<BR><BR>[Calls]<UL><LI><a href="#[250624]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_cmpreturn
+</UL>
+<BR>[Called By]<UL><LI><a href="#[251290]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_fcheck_NaN1
+<LI><a href="#[251614]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN1
+<LI><a href="#[251740]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcheck_NaN2
+</UL>
+
+<P><STRONG><a name="[250624]"></a>__fpl_cmpreturn</STRONG> (ARM, 60 bytes, Stack size 0 bytes, trapv.o(x$fpl$trapveneer), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[250714]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_return_NaN
+<LI><a href="#[251524]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcmp_InfNaN
+</UL>
+
+<P><STRONG><a name="[2511dc]"></a>__I$use$fp</STRONG> (ARM, 0 bytes, Stack size unknown bytes, usenofp.o(x$fpl$usenofp), UNUSED)
+<P>
+<H3>
+Local Symbols
+</H3>
+<P><STRONG><a name="[25375c]"></a>_dadd1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, daddsub_noclz.o(x$fpl$dadd), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[25357c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dsub
+<LI><a href="#[2535f4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_drsb
+</UL>
+
+<P><STRONG><a name="[253720]"></a>_dsub1</STRONG> (ARM, 0 bytes, Stack size unknown bytes, daddsub_noclz.o(x$fpl$dsub), UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[2535f4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_drsb
+<LI><a href="#[2536a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dadd
+</UL>
+
+<P><STRONG><a name="[251f38]"></a>_printf_input_char</STRONG> (Thumb, 10 bytes, Stack size 0 bytes, _printf_char_common.o(.text))
+<BR>[Address Reference Count : 1]<UL><LI> _printf_char_common.o(.text)
+</UL><P>
+<H3>
+Undefined Global Symbols
+</H3>
+<P><STRONG><a name="[253414]"></a>__fpl_infinity</STRONG> (Unknown, 0 bytes, Stack size 0 bytes, UNDEFINED, UNUSED)
+<BR><BR>[Called By]<UL><LI><a href="#[251524]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__fpl_dcmp_InfNaN
+<LI><a href="#[252514]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_f2d
+<LI><a href="#[2527a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dmul
+<LI><a href="#[252d48]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dfixu
+<LI><a href="#[252fdc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dfix
+<LI><a href="#[253234]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_ddiv
+<LI><a href="#[25357c]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dsub
+<LI><a href="#[2536a8]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_dadd
+</UL>
+
+<P><STRONG><a name="[250354]"></a>_call_atexit_fns</STRONG> (ARM, 0 bytes, Stack size 0 bytes, UNDEFINED)
+<BR><BR>[Called By]<UL><LI><a href="#[2503cc]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;exit
+</UL>
+
+<P><STRONG><a name="[251c2c]"></a>_printf_mbtowc</STRONG> (ARM, 0 bytes, Stack size 0 bytes, UNDEFINED)
+<BR><BR>[Called By]<UL><LI><a href="#[251ce0]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_cs_common
+</UL>
+
+<P><STRONG><a name="[25555c]"></a>_printf_post_padding</STRONG> (ARM, 0 bytes, Stack size 0 bytes, UNDEFINED)
+<BR><BR>[Called By]<UL><LI><a href="#[2555d4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_str
+</UL>
+
+<P><STRONG><a name="[255520]"></a>_printf_pre_padding</STRONG> (ARM, 0 bytes, Stack size 0 bytes, UNDEFINED)
+<BR><BR>[Called By]<UL><LI><a href="#[2555d4]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;_printf_str
+</UL>
+<HR></body></html>

+ 4 - 0
microcontroller/EOM_lock.lnp

@@ -0,0 +1,4 @@
+--device DARMAD "aduc702x.o" "demo.o" "irq_arm.o" --strict --scatter "EOM_lock.sct" 
+--autoat --summary_stderr --info summarysizes --map --xref --callgraph --symbols 
+--info sizes --info totals --info unused --info veneers 
+ --list ".\EOM_lock.map" -o "EOM_lock.axf"

+ 982 - 0
microcontroller/EOM_lock.map

@@ -0,0 +1,982 @@
+ARM Linker, RVCT4.0 [Build 524] for uVision [Evaluation]
+
+==============================================================================
+
+Section Cross References
+
+    aduc702x.o(STACK) refers (Special) to heapauxi.o(.text) for __use_two_region_memory
+    aduc702x.o(HEAP) refers (Special) to heapauxi.o(.text) for __use_two_region_memory
+    aduc702x.o(Reset) refers (Special) to heapauxi.o(.text) for __use_two_region_memory
+    aduc702x.o(Reset) refers to irq_arm.o(.text) for Undef_Handler
+    aduc702x.o(Reset) refers to aduc702x.o(STACK) for Stack_Top
+    aduc702x.o(Reset) refers to __main.o(!!!main) for __main
+    aduc702x.o(.text) refers (Special) to heapauxi.o(.text) for __use_two_region_memory
+    aduc702x.o(.text) refers to aduc702x.o(HEAP) for Heap_Mem
+    aduc702x.o(.text) refers to aduc702x.o(STACK) for Stack_Mem
+    demo.o(.text) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.text) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.text) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.text) refers to rt_memclr.o(.text) for __aeabi_memclr
+    demo.o(.text) refers to noretval__2sprintf.o(.text) for __2sprintf
+    demo.o(.text) refers to rt_memcpy.o(.text) for __aeabi_memcpy
+    demo.o(.text) refers to demo.o(.data) for .data
+    demo.o(.text) refers to demo.o(.bss) for .bss
+    demo.o(.text) refers to irq_arm.o(.data) for IRQ
+    demo.o(.text) refers to demo.o(.constdata) for .constdata
+    demo.o(.text) refers to dflt_noclz.o(x$fpl$dfltu) for __aeabi_ui2d
+    demo.o(.text) refers to ddiv.o(x$fpl$ddiv) for __aeabi_ddiv
+    demo.o(.text) refers to f2d.o(x$fpl$f2d) for __aeabi_f2d
+    demo.o(.text) refers to dmul.o(x$fpl$dmul) for __aeabi_dmul
+    demo.o(.text) refers to daddsub_noclz.o(x$fpl$dsub) for __aeabi_dsub
+    demo.o(.text) refers to daddsub_noclz.o(x$fpl$dadd) for __aeabi_dadd
+    demo.o(.text) refers to dfix.o(x$fpl$dfix) for __aeabi_d2iz
+    demo.o(.text) refers to aeabi_sdivfast.o(.text) for __aeabi_idivmod
+    demo.o(.text) refers to daddsub_noclz.o(x$fpl$drsb) for __aeabi_drsub
+    demo.o(.text) refers to dfixu.o(x$fpl$dfixu) for __aeabi_d2uiz
+    demo.o(.text) refers to dleqf.o(x$fpl$dleqf) for __aeabi_cdcmple
+    demo.o(.text) refers to drleqf.o(x$fpl$drleqf) for __aeabi_cdrcmple
+    demo.o(.bss) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.bss) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.bss) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.constdata) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.constdata) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.constdata) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.data) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.data) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.data) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.data) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.data) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.data) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.data) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.data) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.data) refers (Special) to _printf_str.o(.text) for _printf_str
+    demo.o(.data) refers (Special) to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    demo.o(.data) refers (Special) to _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) for _printf_s
+    demo.o(.data) refers (Special) to _printf_str.o(.text) for _printf_str
+    irq_arm.o(.text) refers to irq_arm.o(.data) for .data
+    __2sprintf.o(.text) refers to _printf_char_common.o(.text) for _printf_char_common
+    __2sprintf.o(.text) refers to _sputc.o(.text) for _sputc
+    noretval__2sprintf.o(.text) refers to _printf_char_common.o(.text) for _printf_char_common
+    noretval__2sprintf.o(.text) refers to _sputc.o(.text) for _sputc
+    __printf.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    _printf_str.o(.text) refers (Special) to _printf_char.o(.text) for _printf_cs_common
+    _printf_str.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_flags.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_flags.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags.o(.text) refers to __printf_flags.o(.constdata) for .constdata
+    __printf_ss.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_ss.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_ss.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_ss.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_flags_ss.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_flags_ss.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_ss.o(.text) refers to __printf_flags_ss.o(.constdata) for .constdata
+    __printf_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_wp.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_flags_wp.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_flags_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_wp.o(.text) refers to __printf_flags_wp.o(.constdata) for .constdata
+    __printf_ss_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_ss_wp.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_ss_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_ss_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r1) for __ARM_common_call_via_r1
+    __printf_flags_ss_wp.o(.text) refers to _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) for _printf_percent
+    __printf_flags_ss_wp.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    __printf_flags_ss_wp.o(.text) refers to __printf_flags_ss_wp.o(.constdata) for .constdata
+    _printf_s.o(.ARM.Collect$$_printf_percent$$00000014) refers (Weak) to _printf_char.o(.text) for _printf_string
+    _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000) refers (Special) to _printf_percent_end.o(.ARM.Collect$$_printf_percent$$00000017) for _printf_percent_end
+    rt_memcpy.o(.text) refers to rt_memcpy_w.o(.text) for __aeabi_memcpy4
+    rt_memclr.o(.text) refers to rt_memclr_w.o(.text) for _memset_w
+    aeabi_sdivfast.o(.text_udiv) refers to aeabi_sdivfast.o(.text) for __arm_div4
+    aeabi_sdivfast_div0.o(.text_udiv) refers to aeabi_sdivfast_div0.o(.text) for __arm_div4
+    __main.o(!!!main) refers to rtentry.o(.ARM.Collect$$rtentry$$00000000) for __rt_entry
+    daddsub_noclz.o(x$fpl$dadd) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    daddsub_noclz.o(x$fpl$dadd) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    daddsub_noclz.o(x$fpl$dadd) refers to daddsub_noclz.o(x$fpl$dsub) for _dsub1
+    daddsub_noclz.o(x$fpl$dadd) refers to dcheck.o(x$fpl$dcheck) for __fpl_dcheck_NaN2
+    daddsub_noclz.o(x$fpl$drsb) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    daddsub_noclz.o(x$fpl$drsb) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    daddsub_noclz.o(x$fpl$drsb) refers to daddsub_noclz.o(x$fpl$dadd) for _dadd1
+    daddsub_noclz.o(x$fpl$drsb) refers to daddsub_noclz.o(x$fpl$dsub) for _dsub1
+    daddsub_noclz.o(x$fpl$dsub) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    daddsub_noclz.o(x$fpl$dsub) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    daddsub_noclz.o(x$fpl$dsub) refers to daddsub_noclz.o(x$fpl$dadd) for _dadd1
+    daddsub_noclz.o(x$fpl$dsub) refers to dcheck.o(x$fpl$dcheck) for __fpl_dcheck_NaN2
+    ddiv.o(x$fpl$drdiv) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    ddiv.o(x$fpl$drdiv) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    ddiv.o(x$fpl$drdiv) refers to ddiv.o(x$fpl$ddiv) for ddiv_entry
+    ddiv.o(x$fpl$ddiv) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    ddiv.o(x$fpl$ddiv) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    ddiv.o(x$fpl$ddiv) refers to dcheck.o(x$fpl$dcheck) for __fpl_dcheck_NaN2
+    dfix.o(x$fpl$dfix) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dfix.o(x$fpl$dfix) refers to dcheck1.o(x$fpl$dcheck1) for __fpl_dcheck_NaN1
+    dfix.o(x$fpl$dfixr) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dfix.o(x$fpl$dfixr) refers to dcheck1.o(x$fpl$dcheck1) for __fpl_dcheck_NaN1
+    dfixu.o(x$fpl$dfixu) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dfixu.o(x$fpl$dfixu) refers to dcheck1.o(x$fpl$dcheck1) for __fpl_dcheck_NaN1
+    dfixu.o(x$fpl$dfixur) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dfixu.o(x$fpl$dfixur) refers to dcheck1.o(x$fpl$dcheck1) for __fpl_dcheck_NaN1
+    dflt_noclz.o(x$fpl$dfltu) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dflt_noclz.o(x$fpl$dfltu) refers to dflt_noclz.o(x$fpl$dflt) for __dflt_normalise
+    dflt_noclz.o(x$fpl$dflt) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dleqf.o(x$fpl$dleqf) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dleqf.o(x$fpl$dleqf) refers to dcmpin.o(x$fpl$dcmpinfnan) for __fpl_dcmp_InfNaN
+    dmul.o(x$fpl$dmul) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dmul.o(x$fpl$dmul) refers (Special) to dunder.o(x$fpl$dunder) for __dunder
+    dmul.o(x$fpl$dmul) refers to dcheck.o(x$fpl$dcheck) for __fpl_dcheck_NaN2
+    drleqf.o(x$fpl$drleqf) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    drleqf.o(x$fpl$drleqf) refers to dcmpin.o(x$fpl$dcmpinfnan) for __fpl_dcmp_InfNaN
+    f2d.o(x$fpl$f2d) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    f2d.o(x$fpl$f2d) refers (Special) to dflt_noclz.o(x$fpl$dflt) for __dflt_normalise
+    f2d.o(x$fpl$f2d) refers to fcheck1.o(x$fpl$fcheck1) for __fpl_fcheck_NaN1
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000A) for __rt_entry_li
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000D) for __rt_entry_main
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000C) for __rt_entry_postli_1
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$00000009) for __rt_entry_postsh_1
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$00000002) for __rt_entry_presh_1
+    rtentry.o(.ARM.Collect$$rtentry$$00000000) refers (Special) to rtentry4.o(.ARM.Collect$$rtentry$$00000004) for __rt_entry_sh
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000A) for __rt_entry_li
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000D) for __rt_entry_main
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$0000000C) for __rt_entry_postli_1
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$00000009) for __rt_entry_postsh_1
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry2.o(.ARM.Collect$$rtentry$$00000002) for __rt_entry_presh_1
+    rtentry.o(.ARM.exidx) refers (Special) to rtentry4.o(.ARM.Collect$$rtentry$$00000004) for __rt_entry_sh
+    rtentry.o(.ARM.exidx) refers to rtentry.o(.ARM.Collect$$rtentry$$00000000) for .ARM.Collect$$rtentry$$00000000
+    aeabi_idiv0_sigfpe.o(.text) refers to rt_div0.o(.text) for __rt_div0
+    _printf_char_common.o(.text) refers to __printf.o(.text) for __printf
+    _printf_char.o(.text) refers (Weak) to _printf_str.o(.text) for _printf_str
+    dcheck.o(x$fpl$dcheck) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dcheck.o(x$fpl$dcheck) refers to retnan.o(x$fpl$retnan) for __fpl_return_NaN
+    dcheck1.o(x$fpl$dcheck1) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dcheck1.o(x$fpl$dcheck1) refers to retnan.o(x$fpl$retnan) for __fpl_return_NaN
+    dcmpin.o(x$fpl$dcmpinfnan) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    dcmpin.o(x$fpl$dcmpinfnan) refers to dcheck.o(x$fpl$dcheck) for __fpl_dcheck_NaN2
+    dcmpin.o(x$fpl$dcmpinfnan) refers to trapv.o(x$fpl$trapveneer) for __fpl_cmpreturn
+    dunder.o(x$fpl$dunder) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    fcheck1.o(x$fpl$fcheck1) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    fcheck1.o(x$fpl$fcheck1) refers to retnan.o(x$fpl$retnan) for __fpl_return_NaN
+    rtentry2.o(.ARM.Collect$$rtentry$$00000008) refers to boardinit2.o(.text) for _platform_post_stackheap_init
+    rtentry2.o(.ARM.Collect$$rtentry$$0000000A) refers to libinit.o(.ARM.Collect$$libinit$$00000000) for __rt_lib_init
+    rtentry2.o(.ARM.Collect$$rtentry$$0000000B) refers to boardinit3.o(.text) for _platform_post_lib_init
+    rtentry2.o(.ARM.Collect$$rtentry$$0000000D) refers to exit.o(.text) for exit
+    rtentry2.o(.ARM.Collect$$rtentry$$0000000D) refers to demo.o(.text) for main
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$00000001) for .ARM.Collect$$rtentry$$00000001
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$00000002) for .ARM.Collect$$rtentry$$00000002
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$00000008) for .ARM.Collect$$rtentry$$00000008
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$00000009) for .ARM.Collect$$rtentry$$00000009
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$0000000A) for .ARM.Collect$$rtentry$$0000000A
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$0000000B) for .ARM.Collect$$rtentry$$0000000B
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$0000000C) for .ARM.Collect$$rtentry$$0000000C
+    rtentry2.o(.ARM.exidx) refers to rtentry2.o(.ARM.Collect$$rtentry$$0000000D) for .ARM.Collect$$rtentry$$0000000D
+    rtentry4.o(.ARM.Collect$$rtentry$$00000004) refers to sys_stackheap_outer.o(.text) for __user_setup_stackheap
+    rtentry4.o(.ARM.exidx) refers to rtentry4.o(.ARM.Collect$$rtentry$$00000004) for .ARM.Collect$$rtentry$$00000004
+    rt_div0.o(.text) refers to defsig_fpe_outer.o(.text) for __rt_SIGFPE
+    __printf_nopercent.o(.text) refers to __printf_nopercent.o(i.__ARM_common_call_via_r7) for __ARM_common_call_via_r7
+    __printf_nopercent.o(.text) refers to __printf_nopercent.o(i.__ARM_common_call_via_r5) for __ARM_common_call_via_r5
+    retnan.o(x$fpl$retnan) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    retnan.o(x$fpl$retnan) refers to trapv.o(x$fpl$trapveneer) for __fpl_cmpreturn
+    trapv.o(x$fpl$trapveneer) refers (Special) to usenofp.o(x$fpl$usenofp) for __I$use$fp
+    sys_stackheap_outer.o(.text) refers to libspace.o(.text) for __user_perproc_libspace
+    sys_stackheap_outer.o(.text) refers to aduc702x.o(.text) for __user_initial_stackheap
+    exit.o(.text) refers to rtexit.o(.ARM.Collect$$rtexit$$00000000) for __rt_exit
+    defsig_fpe_outer.o(.text) refers to defsig_fpe_inner.o(.text) for __rt_SIGFPE_inner
+    defsig_fpe_outer.o(.text) refers to defsig_exit.o(.text) for __sig_exit
+    defsig_fpe_formal.o(.text) refers to rt_raise.o(.text) for __rt_raise
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000002A) for __rt_lib_init_alloca_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000028) for __rt_lib_init_argv_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000017) for __rt_lib_init_atexit_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000001D) for __rt_lib_init_clock_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000002E) for __rt_lib_init_cpp_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000002C) for __rt_lib_init_exceptions_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000001B) for __rt_lib_init_fp_trap_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000001F) for __rt_lib_init_getenv_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000006) for __rt_lib_init_heap_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000000D) for __rt_lib_init_lc_collate_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000000F) for __rt_lib_init_lc_ctype_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000011) for __rt_lib_init_lc_monetary_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000013) for __rt_lib_init_lc_numeric_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000015) for __rt_lib_init_lc_time_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000000A) for __rt_lib_init_rand_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$0000002F) for __rt_lib_init_return
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000019) for __rt_lib_init_signal_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000021) for __rt_lib_init_stdio_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers (Special) to libinit2.o(.ARM.Collect$$libinit$$00000008) for __rt_lib_init_user_alloc_1
+    libinit.o(.ARM.Collect$$libinit$$00000000) refers to fpinit.o(x$fpl$fpinit) for _fp_init
+    libspace.o(.text) refers to libspace.o(.bss) for __libspace_start
+    rtexit.o(.ARM.Collect$$rtexit$$00000000) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000004) for __rt_exit_exit
+    rtexit.o(.ARM.Collect$$rtexit$$00000000) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000003) for __rt_exit_ls
+    rtexit.o(.ARM.Collect$$rtexit$$00000000) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000002) for __rt_exit_prels_1
+    rtexit.o(.ARM.exidx) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000004) for __rt_exit_exit
+    rtexit.o(.ARM.exidx) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000003) for __rt_exit_ls
+    rtexit.o(.ARM.exidx) refers (Special) to rtexit2.o(.ARM.Collect$$rtexit$$00000002) for __rt_exit_prels_1
+    rtexit.o(.ARM.exidx) refers to rtexit.o(.ARM.Collect$$rtexit$$00000000) for .ARM.Collect$$rtexit$$00000000
+    rt_raise.o(.text) refers to __raise.o(.text) for __raise
+    rt_raise.o(.text) refers to sys_exit.o(.text) for _sys_exit
+    defsig_exit.o(.text) refers to sys_exit.o(.text) for _sys_exit
+    defsig_fpe_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    libinit2.o(.ARM.Collect$$libinit$$0000000C) refers to libinit2.o(.ARM.Collect$$libinit$$0000000B) for .ARM.Collect$$libinit$$0000000B
+    libinit2.o(.ARM.Collect$$libinit$$0000000E) refers to libinit2.o(.ARM.Collect$$libinit$$0000000B) for .ARM.Collect$$libinit$$0000000B
+    libinit2.o(.ARM.Collect$$libinit$$00000010) refers to libinit2.o(.ARM.Collect$$libinit$$0000000B) for .ARM.Collect$$libinit$$0000000B
+    libinit2.o(.ARM.Collect$$libinit$$00000012) refers to libinit2.o(.ARM.Collect$$libinit$$0000000B) for .ARM.Collect$$libinit$$0000000B
+    libinit2.o(.ARM.Collect$$libinit$$00000014) refers to libinit2.o(.ARM.Collect$$libinit$$0000000B) for .ARM.Collect$$libinit$$0000000B
+    libinit2.o(.ARM.Collect$$libinit$$00000022) refers to argv_veneer.o(.emb_text) for __ARM_argv_veneer
+    libinit2.o(.ARM.Collect$$libinit$$00000023) refers to argv_veneer.o(.emb_text) for __ARM_argv_veneer
+    sys_exit.o(.text) refers to use_no_semi.o(.text) for __I$use$semihosting
+    rtexit2.o(.ARM.Collect$$rtexit$$00000003) refers to libshutdown.o(.ARM.Collect$$libshutdown$$00000000) for __rt_lib_shutdown
+    rtexit2.o(.ARM.Collect$$rtexit$$00000004) refers to sys_exit.o(.text) for _sys_exit
+    rtexit2.o(.ARM.exidx) refers to rtexit2.o(.ARM.Collect$$rtexit$$00000001) for .ARM.Collect$$rtexit$$00000001
+    rtexit2.o(.ARM.exidx) refers to rtexit2.o(.ARM.Collect$$rtexit$$00000002) for .ARM.Collect$$rtexit$$00000002
+    rtexit2.o(.ARM.exidx) refers to rtexit2.o(.ARM.Collect$$rtexit$$00000003) for .ARM.Collect$$rtexit$$00000003
+    rtexit2.o(.ARM.exidx) refers to rtexit2.o(.ARM.Collect$$rtexit$$00000004) for .ARM.Collect$$rtexit$$00000004
+    __raise.o(.text) refers to defsig.o(CL$$defsig) for __default_signal_handler
+    __raise.o(.text) refers to __printf.o(i.__ARM_common_call_via_r2) for __ARM_common_call_via_r2
+    defsig_general.o(.text) refers to sys_wrch.o(.text) for _ttywrch
+    argv_veneer.o(.emb_text) refers to no_argv.o(.text) for __ARM_get_argv
+    sys_wrch.o(.text) refers (Special) to use_no_semi.o(.text) for __I$use$semihosting
+    defsig.o(CL$$defsig) refers to defsig_fpe_inner.o(.text) for __rt_SIGFPE_inner
+    defsig.o(CL$$defsig) refers to defsig_rtmem_inner.o(.text) for __rt_SIGRTMEM_inner
+    _get_argv_nomalloc.o(.text) refers (Special) to hrguard.o(.text) for __heap_region$guard
+    _get_argv_nomalloc.o(.text) refers to defsig_rtmem_outer.o(.text) for __rt_SIGRTMEM
+    _get_argv_nomalloc.o(.text) refers to sys_command.o(.text) for _sys_command_string
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$00000006) for __rt_lib_shutdown_fp_trap_1
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$0000000E) for __rt_lib_shutdown_heap_1
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$0000000F) for __rt_lib_shutdown_return
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$00000009) for __rt_lib_shutdown_signal_1
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$00000003) for __rt_lib_shutdown_stdio_1
+    libshutdown.o(.ARM.Collect$$libshutdown$$00000000) refers (Special) to libshutdown2.o(.ARM.Collect$$libshutdown$$0000000B) for __rt_lib_shutdown_user_alloc_1
+    sys_command.o(.text) refers (Special) to use_no_semi.o(.text) for __I$use$semihosting
+    defsig_abrt_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_rtred_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_rtmem_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_rtmem_outer.o(.text) refers to defsig_rtmem_inner.o(.text) for __rt_SIGRTMEM_inner
+    defsig_rtmem_outer.o(.text) refers to defsig_exit.o(.text) for __sig_exit
+    defsig_rtmem_formal.o(.text) refers to rt_raise.o(.text) for __rt_raise
+    defsig_stak_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_pvfn_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_cppl_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_segv_inner.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+    defsig_other.o(.text) refers to defsig_general.o(.text) for __default_signal_display
+
+
+==============================================================================
+
+Removing Unused input sections from the image.
+
+    Removing demo.o(.data), (2 bytes).
+    Removing demo.o(.data), (2 bytes).
+    Removing demo.o(.data), (4 bytes).
+
+3 unused section(s) (total 8 bytes) removed from the image.
+
+==============================================================================
+
+Adding Veneers to the image
+
+    Adding TA veneer (4 bytes, Inline) for call to '_printf_percent' from __printf.o(.text).
+    Adding AT veneer (8 bytes, Inline) for call to '__rt_lib_init' from rtentry2.o(.ARM.Collect$$rtentry$$0000000A).
+    Adding AT veneer (8 bytes, Inline) for call to '__rt_lib_shutdown' from rtexit2.o(.ARM.Collect$$rtexit$$00000003).
+    Adding TA veneer (4 bytes, Inline) for call to '__rt_exit' from exit.o(.text).
+    Adding AT veneer (8 bytes, Inline) for call to '__2sprintf' from demo.o(.text).
+    Adding AT veneer (8 bytes, Inline) for call to '_printf_string' from _printf_s.o(.ARM.Collect$$_printf_percent$$00000014).
+    Adding TA veneer (4 bytes, Inline) for call to '_fp_init' from libinit.o(.ARM.Collect$$libinit$$00000000).
+
+7 Veneer(s) (total 44 bytes) added to the image.
+
+==============================================================================
+
+Image Symbol Table
+
+    Local Symbols
+
+    Symbol Name                              Value     Ov Type        Size  Object(Section)
+
+    ../../angel/boardlib.s                   0x00000000   Number         0  boardinit2.o ABSOLUTE
+    ../../angel/boardlib.s                   0x00000000   Number         0  boardinit1.o ABSOLUTE
+    ../../angel/boardlib.s                   0x00000000   Number         0  boardinit3.o ABSOLUTE
+    ../../angel/boardlib.s                   0x00000000   Number         0  boardshut.o ABSOLUTE
+    ../../angel/handlers.s                   0x00000000   Number         0  __scatter_copy.o ABSOLUTE
+    ../../angel/handlers.s                   0x00000000   Number         0  __scatter_zi.o ABSOLUTE
+    ../../angel/kernel.s                     0x00000000   Number         0  rtentry4.o ABSOLUTE
+    ../../angel/kernel.s                     0x00000000   Number         0  rtentry2.o ABSOLUTE
+    ../../angel/kernel.s                     0x00000000   Number         0  rtexit.o ABSOLUTE
+    ../../angel/kernel.s                     0x00000000   Number         0  rtexit2.o ABSOLUTE
+    ../../angel/kernel.s                     0x00000000   Number         0  rtentry.o ABSOLUTE
+    ../../angel/rt.s                         0x00000000   Number         0  aeabi_idiv0_sigfpe.o ABSOLUTE
+    ../../angel/rt.s                         0x00000000   Number         0  rt_raise.o ABSOLUTE
+    ../../angel/rt.s                         0x00000000   Number         0  rt_div0.o ABSOLUTE
+    ../../angel/rt.s                         0x00000000   Number         0  aeabi_idiv0.o ABSOLUTE
+    ../../angel/scatter.s                    0x00000000   Number         0  __scatter.o ABSOLUTE
+    ../../angel/startup.s                    0x00000000   Number         0  __main.o ABSOLUTE
+    ../../angel/sys.s                        0x00000000   Number         0  libspace.o ABSOLUTE
+    ../../angel/sys.s                        0x00000000   Number         0  sys_stackheap_outer.o ABSOLUTE
+    ../../angel/sys.s                        0x00000000   Number         0  use_no_semi.o ABSOLUTE
+    ../../angel/sys.s                        0x00000000   Number         0  sys_exit.o ABSOLUTE
+    ../../angel/sysapp.c                     0x00000000   Number         0  sys_wrch.o ABSOLUTE
+    ../../angel/sysapp.c                     0x00000000   Number         0  sys_command.o ABSOLUTE
+    ../../armsys.c                           0x00000000   Number         0  no_argv.o ABSOLUTE
+    ../../armsys.c                           0x00000000   Number         0  _get_argv_nomalloc.o ABSOLUTE
+    ../../armsys.c                           0x00000000   Number         0  argv_veneer.o ABSOLUTE
+    ../../armsys.c                           0x00000000   Number         0  argv_veneer.o ABSOLUTE
+    ../../daddsub.s                          0x00000000   Number         0  daddsub_noclz.o ABSOLUTE
+    ../../dcheck.s                           0x00000000   Number         0  dcheck.o ABSOLUTE
+    ../../dcheck1.s                          0x00000000   Number         0  dcheck1.o ABSOLUTE
+    ../../dcmpin.s                           0x00000000   Number         0  dcmpin.o ABSOLUTE
+    ../../ddiv.s                             0x00000000   Number         0  ddiv.o ABSOLUTE
+    ../../dfix.s                             0x00000000   Number         0  dfix.o ABSOLUTE
+    ../../dfixu.s                            0x00000000   Number         0  dfixu.o ABSOLUTE
+    ../../dflt.s                             0x00000000   Number         0  dflt_noclz.o ABSOLUTE
+    ../../division.s                         0x00000000   Number         0  aeabi_sdivfast.o ABSOLUTE
+    ../../division.s                         0x00000000   Number         0  aeabi_sdivfast_div0.o ABSOLUTE
+    ../../divrt.s                            0x00000000   Number         0  divrt_7tdmi_div0.o ABSOLUTE
+    ../../divrt.s                            0x00000000   Number         0  divrt_7tdmi.o ABSOLUTE
+    ../../dleqf.s                            0x00000000   Number         0  dleqf.o ABSOLUTE
+    ../../dmul.s                             0x00000000   Number         0  dmul.o ABSOLUTE
+    ../../drleqf.s                           0x00000000   Number         0  drleqf.o ABSOLUTE
+    ../../dunder.s                           0x00000000   Number         0  dunder.o ABSOLUTE
+    ../../f2d.s                              0x00000000   Number         0  f2d.o ABSOLUTE
+    ../../fcheck1.s                          0x00000000   Number         0  fcheck1.o ABSOLUTE
+    ../../fpinit.s                           0x00000000   Number         0  fpinit.o ABSOLUTE
+    ../../heapalloc.c                        0x00000000   Number         0  hrguard.o ABSOLUTE
+    ../../heapaux.c                          0x00000000   Number         0  heapauxi.o ABSOLUTE
+    ../../libinit.s                          0x00000000   Number         0  libinit.o ABSOLUTE
+    ../../libinit.s                          0x00000000   Number         0  libshutdown2.o ABSOLUTE
+    ../../libinit.s                          0x00000000   Number         0  libshutdown.o ABSOLUTE
+    ../../libinit.s                          0x00000000   Number         0  libinit2.o ABSOLUTE
+    ../../memcpset.s                         0x00000000   Number         0  rt_memclr_w.o ABSOLUTE
+    ../../memcpset.s                         0x00000000   Number         0  rt_memcpy.o ABSOLUTE
+    ../../memcpset.s                         0x00000000   Number         0  rt_memclr.o ABSOLUTE
+    ../../memcpset.s                         0x00000000   Number         0  rt_memcpy_w.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __2sprintf.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_ss_wp.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_flags_ss_wp.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_wp.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_flags_ss.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_ss.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_flags_wp.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_flags.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  _printf_str.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  _printf_char_common.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  _sputc.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  _printf_char.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  __printf_nopercent.o ABSOLUTE
+    ../../printf.c                           0x00000000   Number         0  noretval__2sprintf.o ABSOLUTE
+    ../../printf_percent.s                   0x00000000   Number         0  _printf_percent_end.o ABSOLUTE
+    ../../printf_percent.s                   0x00000000   Number         0  _printf_percent.o ABSOLUTE
+    ../../printf_percent.s                   0x00000000   Number         0  _printf_s.o ABSOLUTE
+    ../../retnan.s                           0x00000000   Number         0  retnan.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_general.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_rtred_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_rtmem_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_fpe_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_fpe_formal.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_rtmem_outer.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_fpe_outer.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_abrt_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_exit.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  __raise.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_segv_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_rtmem_formal.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_stak_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_pvfn_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_cppl_inner.o ABSOLUTE
+    ../../signal.c                           0x00000000   Number         0  defsig_other.o ABSOLUTE
+    ../../signal.s                           0x00000000   Number         0  defsig.o ABSOLUTE
+    ../../stdlib.c                           0x00000000   Number         0  exit.o ABSOLUTE
+    ../../trapv.s                            0x00000000   Number         0  trapv.o ABSOLUTE
+    ../../usenofp.s                          0x00000000   Number         0  usenofp.o ABSOLUTE
+    ADuC702x.s                               0x00000000   Number         0  aduc702x.o ABSOLUTE
+    Demo.C                                   0x00000000   Number         0  demo.o ABSOLUTE
+    dc.s                                     0x00000000   Number         0  dc.o ABSOLUTE
+    irq_arm.c                                0x00000000   Number         0  irq_arm.o ABSOLUTE
+    .data                                    0x00010000   Section       88  demo.o(.data)
+    .data                                    0x00010058   Section       24  irq_arm.o(.data)
+    .bss                                     0x00010070   Section     2048  demo.o(.bss)
+    .bss                                     0x00010870   Section       96  libspace.o(.bss)
+    HEAP                                     0x000108d0   Section        0  aduc702x.o(HEAP)
+    STACK                                    0x000108d0   Section     1664  aduc702x.o(STACK)
+    Heap_Mem                                 0x000108d0   Data           0  aduc702x.o(HEAP)
+    Stack_Mem                                0x000108d0   Data        1664  aduc702x.o(STACK)
+    Stack_Top                                0x00010f50   Data           0  aduc702x.o(STACK)
+    Reset                                    0x00080000   Section      188  aduc702x.o(Reset)
+    !!!main                                  0x000800bc   Section        8  __main.o(!!!main)
+    !!!scatter                               0x000800c4   Section       60  __scatter.o(!!!scatter)
+    !!handler_copy                           0x00080100   Section       40  __scatter_copy.o(!!handler_copy)
+    !!handler_zi                             0x00080128   Section       44  __scatter_zi.o(!!handler_zi)
+    .ARM.Collect$$_printf_percent$$00000000  0x00080158   Section        0  _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000)
+    .ARM.Collect$$_printf_percent$$00000014  0x00080158   Section        8  _printf_s.o(.ARM.Collect$$_printf_percent$$00000014)
+    .ARM.Collect$$_printf_percent$$00000017  0x00080160   Section        8  _printf_percent_end.o(.ARM.Collect$$_printf_percent$$00000017)
+    .ARM.Collect$$libinit$$00000000          0x00080170   Section        6  libinit.o(.ARM.Collect$$libinit$$00000000)
+    .ARM.Collect$$libinit$$00000006          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000006)
+    .ARM.Collect$$libinit$$00000008          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000008)
+    .ARM.Collect$$libinit$$0000000A          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000000A)
+    .ARM.Collect$$libinit$$0000000D          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000000D)
+    .ARM.Collect$$libinit$$0000000F          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000000F)
+    .ARM.Collect$$libinit$$00000011          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000011)
+    .ARM.Collect$$libinit$$00000013          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000013)
+    .ARM.Collect$$libinit$$00000015          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000015)
+    .ARM.Collect$$libinit$$00000017          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000017)
+    .ARM.Collect$$libinit$$00000019          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000019)
+    .ARM.Collect$$libinit$$0000001B          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000001B)
+    .ARM.Collect$$libinit$$0000001D          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000001D)
+    .ARM.Collect$$libinit$$0000001F          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000001F)
+    .ARM.Collect$$libinit$$00000021          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000021)
+    .ARM.Collect$$libinit$$00000028          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$00000028)
+    .ARM.Collect$$libinit$$0000002A          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000002A)
+    .ARM.Collect$$libinit$$0000002C          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000002C)
+    .ARM.Collect$$libinit$$0000002E          0x00080176   Section        0  libinit2.o(.ARM.Collect$$libinit$$0000002E)
+    .ARM.Collect$$libinit$$0000002F          0x00080176   Section       12  libinit2.o(.ARM.Collect$$libinit$$0000002F)
+    .ARM.Collect$$libshutdown$$00000000      0x0008018c   Section        4  libshutdown.o(.ARM.Collect$$libshutdown$$00000000)
+    .ARM.Collect$$libshutdown$$00000003      0x00080190   Section        0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000003)
+    .ARM.Collect$$libshutdown$$00000006      0x00080190   Section        0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000006)
+    .ARM.Collect$$libshutdown$$00000009      0x00080190   Section        0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000009)
+    .ARM.Collect$$libshutdown$$0000000B      0x00080190   Section        0  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000B)
+    .ARM.Collect$$libshutdown$$0000000E      0x00080190   Section        0  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000E)
+    .ARM.Collect$$libshutdown$$0000000F      0x00080190   Section        6  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000F)
+    .ARM.Collect$$rtentry$$00000000          0x00080198   Section        0  rtentry.o(.ARM.Collect$$rtentry$$00000000)
+    .ARM.Collect$$rtentry$$00000002          0x00080198   Section        0  rtentry2.o(.ARM.Collect$$rtentry$$00000002)
+    .ARM.Collect$$rtentry$$00000004          0x00080198   Section        8  rtentry4.o(.ARM.Collect$$rtentry$$00000004)
+    .ARM.Collect$$rtentry$$00000009          0x000801a0   Section        0  rtentry2.o(.ARM.Collect$$rtentry$$00000009)
+    .ARM.Collect$$rtentry$$0000000A          0x000801a0   Section        4  rtentry2.o(.ARM.Collect$$rtentry$$0000000A)
+    .ARM.Collect$$rtentry$$0000000C          0x000801a4   Section        0  rtentry2.o(.ARM.Collect$$rtentry$$0000000C)
+    .ARM.Collect$$rtentry$$0000000D          0x000801a4   Section       40  rtentry2.o(.ARM.Collect$$rtentry$$0000000D)
+    .ARM.Collect$$rtexit$$00000000           0x000801d0   Section        0  rtexit.o(.ARM.Collect$$rtexit$$00000000)
+    .ARM.Collect$$rtexit$$00000002           0x000801d0   Section        0  rtexit2.o(.ARM.Collect$$rtexit$$00000002)
+    .ARM.Collect$$rtexit$$00000003           0x000801d0   Section        4  rtexit2.o(.ARM.Collect$$rtexit$$00000003)
+    .ARM.Collect$$rtexit$$00000004           0x000801d4   Section        4  rtexit2.o(.ARM.Collect$$rtexit$$00000004)
+    .text                                    0x000801d8   Section       32  aduc702x.o(.text)
+    .text                                    0x000801f8   Section     3092  demo.o(.text)
+    .text                                    0x00080e0c   Section      196  irq_arm.o(.text)
+    .text                                    0x00080ed8   Section       40  noretval__2sprintf.o(.text)
+    .text                                    0x00080f00   Section      120  __printf.o(.text)
+    .text                                    0x00080f78   Section       88  _printf_str.o(.text)
+    .text                                    0x00080fd0   Section      212  rt_memcpy.o(.text)
+    .text                                    0x000810a4   Section       64  rt_memclr.o(.text)
+    .text                                    0x000810e4   Section      556  aeabi_sdivfast.o(.text)
+    __arm_div_large_positive                 0x00081118   ARM Code       0  aeabi_sdivfast.o(.text)
+    __arm_div16                              0x00081140   ARM Code       0  aeabi_sdivfast.o(.text)
+    __arm_div12                              0x00081170   ARM Code       0  aeabi_sdivfast.o(.text)
+    __arm_div8                               0x000811a4   ARM Code       0  aeabi_sdivfast.o(.text)
+    __arm_div4                               0x000811d4   ARM Code       0  aeabi_sdivfast.o(.text)
+    .text                                    0x00081310   Section        6  heapauxi.o(.text)
+    .text                                    0x00081318   Section       52  _printf_char_common.o(.text)
+    _printf_input_char                       0x00081319   Thumb Code    10  _printf_char_common.o(.text)
+    .text                                    0x0008134c   Section       10  _sputc.o(.text)
+    .text                                    0x00081360   Section       50  _printf_char.o(.text)
+    .text                                    0x00081394   Section      100  rt_memcpy_w.o(.text)
+    .text                                    0x000813f8   Section       84  rt_memclr_w.o(.text)
+    .text                                    0x0008144c   Section       96  sys_stackheap_outer.o(.text)
+    .text                                    0x000814ac   Section       12  exit.o(.text)
+    .text                                    0x000814b8   Section       12  libspace.o(.text)
+    .text                                    0x000814c4   Section       24  sys_exit.o(.text)
+    .text                                    0x000814dc   Section        4  use_no_semi.o(.text)
+    i.__ARM_common_call_via_r1               0x000814e0   Section        2  __printf.o(i.__ARM_common_call_via_r1)
+    i.__ARM_common_call_via_r2               0x000814e2   Section        2  __printf.o(i.__ARM_common_call_via_r2)
+    x$fpl$dadd                               0x000814e4   Section      468  daddsub_noclz.o(x$fpl$dadd)
+    _dadd1                                   0x000814f4   ARM Code       0  daddsub_noclz.o(x$fpl$dadd)
+    x$fpl$dcheck                             0x000816b8   Section       16  dcheck.o(x$fpl$dcheck)
+    x$fpl$dcheck1                            0x000816c8   Section       16  dcheck1.o(x$fpl$dcheck1)
+    x$fpl$dcmpinfnan                         0x000816d8   Section      128  dcmpin.o(x$fpl$dcmpinfnan)
+    x$fpl$ddiv                               0x00081758   Section     1116  ddiv.o(x$fpl$ddiv)
+    ddiv_entry                               0x0008175c   ARM Code       0  ddiv.o(x$fpl$ddiv)
+    x$fpl$dfix                               0x00081bb4   Section      176  dfix.o(x$fpl$dfix)
+    x$fpl$dfixu                              0x00081c64   Section      136  dfixu.o(x$fpl$dfixu)
+    x$fpl$dflt                               0x00081cec   Section       88  dflt_noclz.o(x$fpl$dflt)
+    x$fpl$dfltu                              0x00081d44   Section       12  dflt_noclz.o(x$fpl$dfltu)
+    x$fpl$dleqf                              0x00081d50   Section      136  dleqf.o(x$fpl$dleqf)
+    x$fpl$dmul                               0x00081dd8   Section      476  dmul.o(x$fpl$dmul)
+    x$fpl$drleqf                             0x00081fb4   Section      160  drleqf.o(x$fpl$drleqf)
+    x$fpl$drsb                               0x00082054   Section       24  daddsub_noclz.o(x$fpl$drsb)
+    x$fpl$dsub                               0x0008206c   Section      584  daddsub_noclz.o(x$fpl$dsub)
+    _dsub1                                   0x0008207c   ARM Code       0  daddsub_noclz.o(x$fpl$dsub)
+    x$fpl$dunder                             0x000822b4   Section      280  dunder.o(x$fpl$dunder)
+    x$fpl$f2d                                0x000823cc   Section      100  f2d.o(x$fpl$f2d)
+    x$fpl$fcheck1                            0x00082430   Section       12  fcheck1.o(x$fpl$fcheck1)
+    x$fpl$fpinit                             0x00082440   Section        4  fpinit.o(x$fpl$fpinit)
+    x$fpl$retnan                             0x00082444   Section      116  retnan.o(x$fpl$retnan)
+    x$fpl$trapveneer                         0x000824b8   Section       60  trapv.o(x$fpl$trapveneer)
+    .constdata                               0x000824f4   Section       19  demo.o(.constdata)
+    x$fpl$usenofp                            0x000824f4   Section        0  usenofp.o(x$fpl$usenofp)
+    __func__                                 0x000824f4   Data          19  demo.o(.constdata)
+
+    Global Symbols
+
+    Symbol Name                              Value     Ov Type        Size  Object(Section)
+
+    BuildAttributes$$THM_ISAv1$ARM_ISAv4$S$PE$A:L22$X:L11$S22$IEEE1$IW$USESV6$~STKCKD$USESV7$~SHL$OTIME$ROPI$EBA8$UX$STANDARDLIB$REQ8$PRES8$EABIv2 0x00000000   Number         0  anon$$obj.o ABSOLUTE
+    __ARM_use_no_argv                        0x00000000   Number         0  demo.o ABSOLUTE
+    __ARM_exceptions_init                     - Undefined Weak Reference
+    __alloca_initialize                       - Undefined Weak Reference
+    __cpp_initialize__aeabi_                  - Undefined Weak Reference
+    __cxa_finalize                            - Undefined Weak Reference
+    __fpl_infinity                            - Undefined Weak Reference
+    __rt_locale                               - Undefined Weak Reference
+    __sigvec_lookup                           - Undefined Weak Reference
+    _atexit_init                              - Undefined Weak Reference
+    _call_atexit_fns                          - Undefined Weak Reference
+    _clock_init                               - Undefined Weak Reference
+    _fp_trap_init                             - Undefined Weak Reference
+    _fp_trap_shutdown                         - Undefined Weak Reference
+    _get_lc_collate                           - Undefined Weak Reference
+    _get_lc_ctype                             - Undefined Weak Reference
+    _get_lc_monetary                          - Undefined Weak Reference
+    _get_lc_numeric                           - Undefined Weak Reference
+    _get_lc_time                              - Undefined Weak Reference
+    _getenv_init                              - Undefined Weak Reference
+    _handle_redirection                       - Undefined Weak Reference
+    _init_alloc                               - Undefined Weak Reference
+    _init_user_alloc                          - Undefined Weak Reference
+    _initio                                   - Undefined Weak Reference
+    _printf_mbtowc                            - Undefined Weak Reference
+    _printf_post_padding                      - Undefined Weak Reference
+    _printf_pre_padding                       - Undefined Weak Reference
+    _rand_init                                - Undefined Weak Reference
+    _signal_finish                            - Undefined Weak Reference
+    _signal_init                              - Undefined Weak Reference
+    _terminate_alloc                          - Undefined Weak Reference
+    _terminate_user_alloc                     - Undefined Weak Reference
+    _terminateio                              - Undefined Weak Reference
+    Byte_addr                                0x00010000   Data           1  demo.o(.data)
+    pga_state                                0x00010001   Data           1  demo.o(.data)
+    transf                                   0x00010002   Data           1  demo.o(.data)
+    enab_gnd                                 0x00010003   Data           1  demo.o(.data)
+    busy                                     0x00010004   Data           1  demo.o(.data)
+    remote_trigg                             0x00010005   Data           1  demo.o(.data)
+    i                                        0x00010006   Data           2  demo.o(.data)
+    Vlearn                                   0x00010008   Data           2  demo.o(.data)
+    start                                    0x0001000a   Data           2  demo.o(.data)
+    stop                                     0x0001000c   Data           2  demo.o(.data)
+    start_gnd                                0x0001000e   Data           2  demo.o(.data)
+    stop_gnd                                 0x00010010   Data           2  demo.o(.data)
+    Vset                                     0x00010012   Data           2  demo.o(.data)
+    wf_len                                   0x00010014   Data           2  demo.o(.data)
+    step_max                                 0x00010016   Data           2  demo.o(.data)
+    N                                        0x00010018   Data           2  demo.o(.data)
+    auto_set_pga                             0x0001001a   Data           2  demo.o(.data)
+    coarse_fine_ratio                        0x0001001c   Data           2  demo.o(.data)
+    mode                                     0x0001001e   Data           2  demo.o(.data)
+    out_of_lock                              0x00010020   Data           2  demo.o(.data)
+    first                                    0x00010024   Data           4  demo.o(.data)
+    i2c_cnt                                  0x00010028   Data           4  demo.o(.data)
+    trigg_cnt                                0x0001002c   Data           4  demo.o(.data)
+    v_cnt                                    0x00010030   Data           4  demo.o(.data)
+    wf_cnt                                   0x00010034   Data           4  demo.o(.data)
+    Gain                                     0x00010038   Data           4  demo.o(.data)
+    pbuff                                    0x0001003c   Data           4  demo.o(.data)
+    Vout                                     0x00010040   Data           8  demo.o(.data)
+    Vin                                      0x00010048   Data           8  demo.o(.data)
+    Vin_gnd                                  0x00010050   Data           8  demo.o(.data)
+    IRQ                                      0x00010058   Data           4  irq_arm.o(.data)
+    SWI                                      0x0001005c   Data           4  irq_arm.o(.data)
+    FIQ                                      0x00010060   Data           4  irq_arm.o(.data)
+    UNDEF                                    0x00010064   Data           4  irq_arm.o(.data)
+    PABORT                                   0x00010068   Data           4  irq_arm.o(.data)
+    DABORT                                   0x0001006c   Data           4  irq_arm.o(.data)
+    BigDat                                   0x00010070   Data         512  demo.o(.bss)
+    text                                     0x00010270   Data         512  demo.o(.bss)
+    plist                                    0x00010470   Data        1024  demo.o(.bss)
+    __libspace_start                         0x00010870   Data          96  libspace.o(.bss)
+    __temporary_stack_top$libspace           0x000108d0   Data           0  libspace.o(.bss)
+    Reset_Handler                            0x00080040   ARM Code       0  aduc702x.o(Reset)
+    __main                                   0x000800bc   ARM Code       8  __main.o(!!!main)
+    __scatterload                            0x000800c4   ARM Code       0  __scatter.o(!!!scatter)
+    __scatterload_rt2                        0x000800c4   ARM Code      52  __scatter.o(!!!scatter)
+    __scatterload_null                       0x000800d8   ARM Code       0  __scatter.o(!!!scatter)
+    __scatterload_copy                       0x00080100   ARM Code      40  __scatter_copy.o(!!handler_copy)
+    __scatterload_zeroinit                   0x00080128   ARM Code      44  __scatter_zi.o(!!handler_zi)
+    Inline Thumb to ARM Veneer to _printf_percent 0x00080155   Thumb Code     4  _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000)
+    _printf_percent                          0x00080158   ARM Code       0  _printf_percent.o(.ARM.Collect$$_printf_percent$$00000000)
+    _printf_s                                0x00080158   ARM Code       0  _printf_s.o(.ARM.Collect$$_printf_percent$$00000014)
+    _printf_percent_end                      0x00080160   ARM Code       0  _printf_percent_end.o(.ARM.Collect$$_printf_percent$$00000017)
+    Inline ARM to Thumb Veneer to __rt_lib_init 0x00080168   ARM Code       8  libinit.o(.ARM.Collect$$libinit$$00000000)
+    __rt_lib_init                            0x00080171   Thumb Code     0  libinit.o(.ARM.Collect$$libinit$$00000000)
+    __rt_lib_init_alloca_1                   0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000002A)
+    __rt_lib_init_argv_1                     0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000028)
+    __rt_lib_init_atexit_1                   0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000017)
+    __rt_lib_init_clock_1                    0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000001D)
+    __rt_lib_init_cpp_1                      0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000002E)
+    __rt_lib_init_exceptions_1               0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000002C)
+    __rt_lib_init_fp_trap_1                  0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000001B)
+    __rt_lib_init_getenv_1                   0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000001F)
+    __rt_lib_init_heap_1                     0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000006)
+    __rt_lib_init_lc_collate_1               0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000000D)
+    __rt_lib_init_lc_ctype_1                 0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000000F)
+    __rt_lib_init_lc_monetary_1              0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000011)
+    __rt_lib_init_lc_numeric_1               0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000013)
+    __rt_lib_init_lc_time_1                  0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000015)
+    __rt_lib_init_rand_1                     0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000000A)
+    __rt_lib_init_return                     0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$0000002F)
+    __rt_lib_init_signal_1                   0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000019)
+    __rt_lib_init_stdio_1                    0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000021)
+    __rt_lib_init_user_alloc_1               0x00080177   Thumb Code     0  libinit2.o(.ARM.Collect$$libinit$$00000008)
+    Inline ARM to Thumb Veneer to __rt_lib_shutdown 0x00080184   ARM Code       8  libshutdown.o(.ARM.Collect$$libshutdown$$00000000)
+    __rt_lib_shutdown                        0x0008018d   Thumb Code     0  libshutdown.o(.ARM.Collect$$libshutdown$$00000000)
+    __rt_lib_shutdown_fp_trap_1              0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000006)
+    __rt_lib_shutdown_heap_1                 0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000E)
+    __rt_lib_shutdown_return                 0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000F)
+    __rt_lib_shutdown_signal_1               0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000009)
+    __rt_lib_shutdown_stdio_1                0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$00000003)
+    __rt_lib_shutdown_user_alloc_1           0x00080191   Thumb Code     0  libshutdown2.o(.ARM.Collect$$libshutdown$$0000000B)
+    __rt_entry                               0x00080198   ARM Code       0  rtentry.o(.ARM.Collect$$rtentry$$00000000)
+    __rt_entry_presh_1                       0x00080198   ARM Code       0  rtentry2.o(.ARM.Collect$$rtentry$$00000002)
+    __rt_entry_sh                            0x00080198   ARM Code       0  rtentry4.o(.ARM.Collect$$rtentry$$00000004)
+    __rt_entry_li                            0x000801a0   ARM Code       0  rtentry2.o(.ARM.Collect$$rtentry$$0000000A)
+    __rt_entry_postsh_1                      0x000801a0   ARM Code       0  rtentry2.o(.ARM.Collect$$rtentry$$00000009)
+    __rt_entry_main                          0x000801a4   ARM Code       0  rtentry2.o(.ARM.Collect$$rtentry$$0000000D)
+    __rt_entry_postli_1                      0x000801a4   ARM Code       0  rtentry2.o(.ARM.Collect$$rtentry$$0000000C)
+    Inline Thumb to ARM Veneer to __rt_exit  0x000801cd   Thumb Code     4  rtexit.o(.ARM.Collect$$rtexit$$00000000)
+    __rt_exit                                0x000801d0   ARM Code       0  rtexit.o(.ARM.Collect$$rtexit$$00000000)
+    __rt_exit_ls                             0x000801d0   ARM Code       0  rtexit2.o(.ARM.Collect$$rtexit$$00000003)
+    __rt_exit_prels_1                        0x000801d0   ARM Code       0  rtexit2.o(.ARM.Collect$$rtexit$$00000002)
+    __rt_exit_exit                           0x000801d4   ARM Code       0  rtexit2.o(.ARM.Collect$$rtexit$$00000004)
+    __user_initial_stackheap                 0x000801d8   ARM Code       0  aduc702x.o(.text)
+    delay                                    0x000801f8   ARM Code       4  demo.o(.text)
+    ADCtoDAT                                 0x000801fc   ARM Code      12  demo.o(.text)
+    DATtoADC                                 0x00080208   ARM Code       8  demo.o(.text)
+    DATtoDAC                                 0x00080210   ARM Code       8  demo.o(.text)
+    Read_Digital                             0x00080218   ARM Code      24  demo.o(.text)
+    Write_Digital                            0x00080230   ARM Code      40  demo.o(.text)
+    ADCpoweron                               0x00080258   ARM Code      20  demo.o(.text)
+    get_DACs                                 0x0008026c   ARM Code      64  demo.o(.text)
+    set_DACs                                 0x000802ac   ARM Code      64  demo.o(.text)
+    set_pga                                  0x000802ec   ARM Code      56  demo.o(.text)
+    get_pga                                  0x00080324   ARM Code      84  demo.o(.text)
+    My_IRQ_Handler                           0x00080378   ARM Code     472  demo.o(.text)
+    lock_StabPulse_i2c                       0x00080550   ARM Code    2216  demo.o(.text)
+    main                                     0x00080df8   ARM Code      20  demo.o(.text)
+    IRQ_Handler                              0x00080e0c   ARM Code      32  irq_arm.o(.text)
+    FIQ_Handler                              0x00080e2c   ARM Code      32  irq_arm.o(.text)
+    SWI_Handler                              0x00080e4c   ARM Code      32  irq_arm.o(.text)
+    Undef_Handler                            0x00080e6c   ARM Code      32  irq_arm.o(.text)
+    PAbt_Handler                             0x00080e8c   ARM Code      32  irq_arm.o(.text)
+    DAbt_Handler                             0x00080eac   ARM Code      32  irq_arm.o(.text)
+    Inline ARM to Thumb Veneer to __2sprintf 0x00080ed0   ARM Code       8  noretval__2sprintf.o(.text)
+    __2sprintf                               0x00080ed9   Thumb Code    36  noretval__2sprintf.o(.text)
+    __printf                                 0x00080f01   Thumb Code   120  __printf.o(.text)
+    _printf_str                              0x00080f79   Thumb Code    88  _printf_str.o(.text)
+    __aeabi_memcpy                           0x00080fd0   ARM Code       0  rt_memcpy.o(.text)
+    __rt_memcpy                              0x00080fd0   ARM Code     212  rt_memcpy.o(.text)
+    _memcpy_lastbytes                        0x00081084   ARM Code       0  rt_memcpy.o(.text)
+    __aeabi_memclr                           0x000810a4   ARM Code       0  rt_memclr.o(.text)
+    __rt_memclr                              0x000810a4   ARM Code      64  rt_memclr.o(.text)
+    _memset                                  0x000810a8   ARM Code       0  rt_memclr.o(.text)
+    __aeabi_idiv                             0x000810e4   ARM Code       0  aeabi_sdivfast.o(.text)
+    __aeabi_idivmod                          0x000810e4   ARM Code     556  aeabi_sdivfast.o(.text)
+    __use_two_region_memory                  0x00081311   Thumb Code     2  heapauxi.o(.text)
+    __rt_heap_escrow$2region                 0x00081313   Thumb Code     2  heapauxi.o(.text)
+    __rt_heap_expand$2region                 0x00081315   Thumb Code     2  heapauxi.o(.text)
+    _printf_char_common                      0x00081323   Thumb Code    38  _printf_char_common.o(.text)
+    _sputc                                   0x0008134d   Thumb Code    10  _sputc.o(.text)
+    Inline ARM to Thumb Veneer to _printf_string 0x00081358   ARM Code       8  _printf_char.o(.text)
+    _printf_cs_common                        0x00081361   Thumb Code    26  _printf_char.o(.text)
+    _printf_char                             0x0008137b   Thumb Code    16  _printf_char.o(.text)
+    _printf_string                           0x0008138b   Thumb Code     8  _printf_char.o(.text)
+    __aeabi_memcpy4                          0x00081394   ARM Code       0  rt_memcpy_w.o(.text)
+    __aeabi_memcpy8                          0x00081394   ARM Code       0  rt_memcpy_w.o(.text)
+    __rt_memcpy_w                            0x00081394   ARM Code     100  rt_memcpy_w.o(.text)
+    _memcpy_lastbytes_aligned                0x000813e0   ARM Code       0  rt_memcpy_w.o(.text)
+    __aeabi_memclr4                          0x000813f8   ARM Code       0  rt_memclr_w.o(.text)
+    __aeabi_memclr8                          0x000813f8   ARM Code       0  rt_memclr_w.o(.text)
+    __rt_memclr_w                            0x000813f8   ARM Code      84  rt_memclr_w.o(.text)
+    _memset_w                                0x000813fc   ARM Code       0  rt_memclr_w.o(.text)
+    __user_setup_stackheap                   0x0008144c   ARM Code      96  sys_stackheap_outer.o(.text)
+    exit                                     0x000814ad   Thumb Code    12  exit.o(.text)
+    __user_libspace                          0x000814b8   ARM Code      12  libspace.o(.text)
+    __user_perproc_libspace                  0x000814b8   ARM Code       0  libspace.o(.text)
+    __user_perthread_libspace                0x000814b8   ARM Code       0  libspace.o(.text)
+    _sys_exit                                0x000814c4   ARM Code      20  sys_exit.o(.text)
+    __I$use$semihosting                      0x000814dc   ARM Code       0  use_no_semi.o(.text)
+    __use_no_semihosting_swi                 0x000814dc   ARM Code       4  use_no_semi.o(.text)
+    __ARM_common_call_via_r1                 0x000814e1   Thumb Code     2  __printf.o(i.__ARM_common_call_via_r1)
+    __ARM_common_call_via_r2                 0x000814e3   Thumb Code     2  __printf.o(i.__ARM_common_call_via_r2)
+    __aeabi_dadd                             0x000814e4   ARM Code       0  daddsub_noclz.o(x$fpl$dadd)
+    _dadd                                    0x000814e4   ARM Code     452  daddsub_noclz.o(x$fpl$dadd)
+    __fpl_inf_dadd                           0x00081660   ARM Code       0  daddsub_noclz.o(x$fpl$dadd)
+    __fpl_dcheck_NaN2                        0x000816b8   ARM Code      12  dcheck.o(x$fpl$dcheck)
+    __fpl_dcheck_NaN1                        0x000816c8   ARM Code      12  dcheck1.o(x$fpl$dcheck1)
+    __fpl_dcmp_InfNaN                        0x000816d8   ARM Code     128  dcmpin.o(x$fpl$dcmpinfnan)
+    __fpl_inf_dcmp                           0x000816fc   ARM Code       0  dcmpin.o(x$fpl$dcmpinfnan)
+    __aeabi_ddiv                             0x00081758   ARM Code       0  ddiv.o(x$fpl$ddiv)
+    _ddiv                                    0x00081758   ARM Code     464  ddiv.o(x$fpl$ddiv)
+    __fpl_inf_ddiv                           0x000818e4   ARM Code       0  ddiv.o(x$fpl$ddiv)
+    _ddiv_mantissas                          0x00081928   ARM Code     380  ddiv.o(x$fpl$ddiv)
+    __aeabi_d2iz                             0x00081bb4   ARM Code       0  dfix.o(x$fpl$dfix)
+    _dfix                                    0x00081bb4   ARM Code     172  dfix.o(x$fpl$dfix)
+    __fpl_inf_dfix                           0x00081c54   ARM Code       0  dfix.o(x$fpl$dfix)
+    __aeabi_d2uiz                            0x00081c64   ARM Code       0  dfixu.o(x$fpl$dfixu)
+    _dfixu                                   0x00081c64   ARM Code     132  dfixu.o(x$fpl$dfixu)
+    __fpl_inf_dfixu                          0x00081ce0   ARM Code       0  dfixu.o(x$fpl$dfixu)
+    __aeabi_i2d                              0x00081cec   ARM Code       0  dflt_noclz.o(x$fpl$dflt)
+    _dflt                                    0x00081cec   ARM Code      88  dflt_noclz.o(x$fpl$dflt)
+    __dflt_normalise                         0x00081cfc   ARM Code       0  dflt_noclz.o(x$fpl$dflt)
+    __aeabi_ui2d                             0x00081d44   ARM Code       0  dflt_noclz.o(x$fpl$dfltu)
+    _dfltu                                   0x00081d44   ARM Code      12  dflt_noclz.o(x$fpl$dfltu)
+    __aeabi_cdcmple                          0x00081d50   ARM Code       0  dleqf.o(x$fpl$dleqf)
+    _dcmple                                  0x00081d50   ARM Code     132  dleqf.o(x$fpl$dleqf)
+    __aeabi_dmul                             0x00081dd8   ARM Code       0  dmul.o(x$fpl$dmul)
+    _dmul                                    0x00081dd8   ARM Code     460  dmul.o(x$fpl$dmul)
+    __fpl_inf_dmul                           0x00081f70   ARM Code       0  dmul.o(x$fpl$dmul)
+    __aeabi_cdrcmple                         0x00081fb4   ARM Code       0  drleqf.o(x$fpl$drleqf)
+    _drcmple                                 0x00081fb4   ARM Code     156  drleqf.o(x$fpl$drleqf)
+    __aeabi_drsub                            0x00082054   ARM Code       0  daddsub_noclz.o(x$fpl$drsb)
+    _drsb                                    0x00082054   ARM Code      24  daddsub_noclz.o(x$fpl$drsb)
+    __aeabi_dsub                             0x0008206c   ARM Code       0  daddsub_noclz.o(x$fpl$dsub)
+    _dsub                                    0x0008206c   ARM Code     572  daddsub_noclz.o(x$fpl$dsub)
+    __fpl_inf_dsub                           0x00082260   ARM Code       0  daddsub_noclz.o(x$fpl$dsub)
+    __dunder                                 0x000822b4   ARM Code     276  dunder.o(x$fpl$dunder)
+    __dunder_d                               0x000823c8   ARM Code       4  dunder.o(x$fpl$dunder)
+    __aeabi_f2d                              0x000823cc   ARM Code       0  f2d.o(x$fpl$f2d)
+    _f2d                                     0x000823cc   ARM Code      96  f2d.o(x$fpl$f2d)
+    __fpl_inf_f2d                            0x00082420   ARM Code       0  f2d.o(x$fpl$f2d)
+    __fpl_fcheck_NaN1                        0x00082430   ARM Code       8  fcheck1.o(x$fpl$fcheck1)
+    Inline Thumb to ARM Veneer to _fp_init   0x0008243d   Thumb Code     4  fpinit.o(x$fpl$fpinit)
+    __fplib_config_pureend_doubles           0x00082440   ARM Code       0  fpinit.o(x$fpl$fpinit)
+    _fp_init                                 0x00082440   ARM Code       4  fpinit.o(x$fpl$fpinit)
+    __fpl_return_NaN                         0x00082444   ARM Code     116  retnan.o(x$fpl$retnan)
+    __fpl_cmpreturn                          0x000824b8   ARM Code      60  trapv.o(x$fpl$trapveneer)
+    __I$use$fp                               0x000824f4   ARM Code       0  usenofp.o(x$fpl$usenofp)
+    Region$$Table$$Base                      0x00082508   Number         0  anon$$obj.o(Region$$Table)
+    Region$$Table$$Limit                     0x00082528   Number         0  anon$$obj.o(Region$$Table)
+
+
+
+==============================================================================
+
+Memory Map of the image
+
+  Image Entry point : 0x000800bc
+
+  Load Region LR_IROM1 (Base: 0x00080000, Size: 0x00002598, Max: 0x0000f800, ABSOLUTE)
+
+    Execution Region ER_IROM1 (Base: 0x00080000, Size: 0x00002528, Max: 0x0000f800, ABSOLUTE)
+
+    Base Addr    Size         Type   Attr      Idx    E Section Name        Object
+
+    0x00080000   0x000000bc   Code   RO            3    Reset               aduc702x.o
+    0x000800bc   0x00000008   Code   RO          144  * !!!main             __main.o(c_t.l)
+    0x000800c4   0x0000003c   Code   RO          373    !!!scatter          __scatter.o(c_t.l)
+    0x00080100   0x00000028   Code   RO          375    !!handler_copy      __scatter_copy.o(c_t.l)
+    0x00080128   0x0000002c   Code   RO          377    !!handler_zi        __scatter_zi.o(c_t.l)
+    0x00080154   0x00000004   Ven    RO          121    .ARM.Collect$$_printf_percent$$00000000  _printf_percent.o(c_t.l)
+    0x00080158   0x00000000   Code   RO          121    .ARM.Collect$$_printf_percent$$00000000  _printf_percent.o(c_t.l)
+    0x00080158   0x00000008   Code   RO          120    .ARM.Collect$$_printf_percent$$00000014  _printf_s.o(c_t.l)
+    0x00080160   0x00000008   Code   RO          188    .ARM.Collect$$_printf_percent$$00000017  _printf_percent_end.o(c_t.l)
+    0x00080168   0x00000008   Ven    RO          248    .ARM.Collect$$libinit$$00000000  libinit.o(c_t.l)
+    0x00080170   0x00000006   Code   RO          248    .ARM.Collect$$libinit$$00000000  libinit.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          262    .ARM.Collect$$libinit$$00000006  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          264    .ARM.Collect$$libinit$$00000008  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          266    .ARM.Collect$$libinit$$0000000A  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          269    .ARM.Collect$$libinit$$0000000D  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          271    .ARM.Collect$$libinit$$0000000F  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          273    .ARM.Collect$$libinit$$00000011  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          275    .ARM.Collect$$libinit$$00000013  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          277    .ARM.Collect$$libinit$$00000015  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          279    .ARM.Collect$$libinit$$00000017  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          281    .ARM.Collect$$libinit$$00000019  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          283    .ARM.Collect$$libinit$$0000001B  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          285    .ARM.Collect$$libinit$$0000001D  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          287    .ARM.Collect$$libinit$$0000001F  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          289    .ARM.Collect$$libinit$$00000021  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          293    .ARM.Collect$$libinit$$00000028  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          295    .ARM.Collect$$libinit$$0000002A  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          297    .ARM.Collect$$libinit$$0000002C  libinit2.o(c_t.l)
+    0x00080176   0x00000000   Code   RO          299    .ARM.Collect$$libinit$$0000002E  libinit2.o(c_t.l)
+    0x00080176   0x0000000c   Code   RO          300    .ARM.Collect$$libinit$$0000002F  libinit2.o(c_t.l)
+    0x00080182   0x00000002   PAD
+    0x00080184   0x00000008   Ven    RO          331    .ARM.Collect$$libshutdown$$00000000  libshutdown.o(c_t.l)
+    0x0008018c   0x00000004   Code   RO          331    .ARM.Collect$$libshutdown$$00000000  libshutdown.o(c_t.l)
+    0x00080190   0x00000000   Code   RO          358    .ARM.Collect$$libshutdown$$00000003  libshutdown2.o(c_t.l)
+    0x00080190   0x00000000   Code   RO          361    .ARM.Collect$$libshutdown$$00000006  libshutdown2.o(c_t.l)
+    0x00080190   0x00000000   Code   RO          364    .ARM.Collect$$libshutdown$$00000009  libshutdown2.o(c_t.l)
+    0x00080190   0x00000000   Code   RO          366    .ARM.Collect$$libshutdown$$0000000B  libshutdown2.o(c_t.l)
+    0x00080190   0x00000000   Code   RO          369    .ARM.Collect$$libshutdown$$0000000E  libshutdown2.o(c_t.l)
+    0x00080190   0x00000006   Code   RO          370    .ARM.Collect$$libshutdown$$0000000F  libshutdown2.o(c_t.l)
+    0x00080196   0x00000002   PAD
+    0x00080198   0x00000000   Code   RO          176    .ARM.Collect$$rtentry$$00000000  rtentry.o(c_t.l)
+    0x00080198   0x00000000   Code   RO          205    .ARM.Collect$$rtentry$$00000002  rtentry2.o(c_t.l)
+    0x00080198   0x00000008   Code   RO          220    .ARM.Collect$$rtentry$$00000004  rtentry4.o(c_t.l)
+    0x000801a0   0x00000000   Code   RO          207    .ARM.Collect$$rtentry$$00000009  rtentry2.o(c_t.l)
+    0x000801a0   0x00000004   Code   RO          208    .ARM.Collect$$rtentry$$0000000A  rtentry2.o(c_t.l)
+    0x000801a4   0x00000000   Code   RO          210    .ARM.Collect$$rtentry$$0000000C  rtentry2.o(c_t.l)
+    0x000801a4   0x00000028   Code   RO          211    .ARM.Collect$$rtentry$$0000000D  rtentry2.o(c_t.l)
+    0x000801cc   0x00000004   Ven    RO          252    .ARM.Collect$$rtexit$$00000000  rtexit.o(c_t.l)
+    0x000801d0   0x00000000   Code   RO          252    .ARM.Collect$$rtexit$$00000000  rtexit.o(c_t.l)
+    0x000801d0   0x00000000   Code   RO          306    .ARM.Collect$$rtexit$$00000002  rtexit2.o(c_t.l)
+    0x000801d0   0x00000004   Code   RO          307    .ARM.Collect$$rtexit$$00000003  rtexit2.o(c_t.l)
+    0x000801d4   0x00000004   Code   RO          308    .ARM.Collect$$rtexit$$00000004  rtexit2.o(c_t.l)
+    0x000801d8   0x00000020   Code   RO            4    .text               aduc702x.o
+    0x000801f8   0x00000c14   Code   RO           11    .text               demo.o
+    0x00080e0c   0x000000c4   Code   RO           74    .text               irq_arm.o
+    0x00080ed0   0x00000008   Ven    RO           92    .text               noretval__2sprintf.o(c_t.l)
+    0x00080ed8   0x00000028   Code   RO           92    .text               noretval__2sprintf.o(c_t.l)
+    0x00080f00   0x00000078   Code   RO           94    .text               __printf.o(c_t.l)
+    0x00080f78   0x00000058   Code   RO          100    .text               _printf_str.o(c_t.l)
+    0x00080fd0   0x000000d4   Code   RO          122    .text               rt_memcpy.o(c_t.l)
+    0x000810a4   0x00000040   Code   RO          124    .text               rt_memclr.o(c_t.l)
+    0x000810e4   0x0000022c   Code   RO          126    .text               aeabi_sdivfast.o(c_t.l)
+    0x00081310   0x00000006   Code   RO          142    .text               heapauxi.o(c_t.l)
+    0x00081316   0x00000002   PAD
+    0x00081318   0x00000034   Code   RO          182    .text               _printf_char_common.o(c_t.l)
+    0x0008134c   0x0000000a   Code   RO          184    .text               _sputc.o(c_t.l)
+    0x00081356   0x00000002   PAD
+    0x00081358   0x00000008   Ven    RO          186    .text               _printf_char.o(c_t.l)
+    0x00081360   0x00000032   Code   RO          186    .text               _printf_char.o(c_t.l)
+    0x00081392   0x00000002   PAD
+    0x00081394   0x00000064   Code   RO          189    .text               rt_memcpy_w.o(c_t.l)
+    0x000813f8   0x00000054   Code   RO          191    .text               rt_memclr_w.o(c_t.l)
+    0x0008144c   0x00000060   Code   RO          234    .text               sys_stackheap_outer.o(c_t.l)
+    0x000814ac   0x0000000c   Code   RO          236    .text               exit.o(c_t.l)
+    0x000814b8   0x0000000c   Code   RO          249    .text               libspace.o(c_t.l)
+    0x000814c4   0x00000018   Code   RO          303    .text               sys_exit.o(c_t.l)
+    0x000814dc   0x00000004   Code   RO          321    .text               use_no_semi.o(c_t.l)
+    0x000814e0   0x00000002   Code   RO           98    i.__ARM_common_call_via_r1  __printf.o(c_t.l)
+    0x000814e2   0x00000002   Code   RO           96    i.__ARM_common_call_via_r2  __printf.o(c_t.l)
+    0x000814e4   0x000001d4   Code   RO          146    x$fpl$dadd          daddsub_noclz.o(fz_ts.l)
+    0x000816b8   0x00000010   Code   RO          193    x$fpl$dcheck        dcheck.o(fz_ts.l)
+    0x000816c8   0x00000010   Code   RO          195    x$fpl$dcheck1       dcheck1.o(fz_ts.l)
+    0x000816d8   0x00000080   Code   RO          197    x$fpl$dcmpinfnan    dcmpin.o(fz_ts.l)
+    0x00081758   0x0000045c   Code   RO          153    x$fpl$ddiv          ddiv.o(fz_ts.l)
+    0x00081bb4   0x000000b0   Code   RO          156    x$fpl$dfix          dfix.o(fz_ts.l)
+    0x00081c64   0x00000088   Code   RO          160    x$fpl$dfixu         dfixu.o(fz_ts.l)
+    0x00081cec   0x00000058   Code   RO          165    x$fpl$dflt          dflt_noclz.o(fz_ts.l)
+    0x00081d44   0x0000000c   Code   RO          164    x$fpl$dfltu         dflt_noclz.o(fz_ts.l)
+    0x00081d50   0x00000088   Code   RO          168    x$fpl$dleqf         dleqf.o(fz_ts.l)
+    0x00081dd8   0x000001dc   Code   RO          170    x$fpl$dmul          dmul.o(fz_ts.l)
+    0x00081fb4   0x000000a0   Code   RO          172    x$fpl$drleqf        drleqf.o(fz_ts.l)
+    0x00082054   0x00000018   Code   RO          147    x$fpl$drsb          daddsub_noclz.o(fz_ts.l)
+    0x0008206c   0x00000248   Code   RO          148    x$fpl$dsub          daddsub_noclz.o(fz_ts.l)
+    0x000822b4   0x00000118   Code   RO          199    x$fpl$dunder        dunder.o(fz_ts.l)
+    0x000823cc   0x00000064   Code   RO          174    x$fpl$f2d           f2d.o(fz_ts.l)
+    0x00082430   0x0000000c   Code   RO          201    x$fpl$fcheck1       fcheck1.o(fz_ts.l)
+    0x0008243c   0x00000004   Ven    RO          301    x$fpl$fpinit        fpinit.o(fz_ts.l)
+    0x00082440   0x00000004   Code   RO          301    x$fpl$fpinit        fpinit.o(fz_ts.l)
+    0x00082444   0x00000074   Code   RO          230    x$fpl$retnan        retnan.o(fz_ts.l)
+    0x000824b8   0x0000003c   Code   RO          232    x$fpl$trapveneer    trapv.o(fz_ts.l)
+    0x000824f4   0x00000000   Code   RO          203    x$fpl$usenofp       usenofp.o(fz_ts.l)
+    0x000824f4   0x00000013   Data   RO           13    .constdata          demo.o
+    0x00082507   0x00000001   PAD
+    0x00082508   0x00000020   Data   RO          371    Region$$Table       anon$$obj.o
+
+
+    Execution Region RW_IRAM1 (Base: 0x00010000, Size: 0x00000f50, Max: 0x00002000, ABSOLUTE)
+
+    Base Addr    Size         Type   Attr      Idx    E Section Name        Object
+
+    0x00010000   0x00000058   Data   RW           14    .data               demo.o
+    0x00010058   0x00000018   Data   RW           75    .data               irq_arm.o
+    0x00010070   0x00000800   Zero   RW           12    .bss                demo.o
+    0x00010870   0x00000060   Zero   RW          250    .bss                libspace.o(c_t.l)
+    0x000108d0   0x00000000   Zero   RW            2    HEAP                aduc702x.o
+    0x000108d0   0x00000680   Zero   RW            1    STACK               aduc702x.o
+
+
+==============================================================================
+
+Image component sizes
+
+
+      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Object Name
+
+       220         60          0          0       1664        420   aduc702x.o
+      3092        144         19         88       2048       9184   demo.o
+       196          4          0         24          0       1660   irq_arm.o
+
+    ----------------------------------------------------------------------
+      3508        208         52        112       3712      11264   Object Totals
+         0          0         32          0          0          0   (incl. Generated)
+         0          0          1          0          0          0   (incl. Padding)
+
+    ----------------------------------------------------------------------
+
+      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Library Member Name
+
+         8          0          0          0          0         68   __main.o
+       124          0          0          0          0        204   __printf.o
+        60          8          0          0          0          0   __scatter.o
+        40          0          0          0          0          0   __scatter_copy.o
+        44          0          0          0          0          0   __scatter_zi.o
+        58          0          0          0          0        108   _printf_char.o
+        52          4          0          0          0        100   _printf_char_common.o
+         4          0          0          0          0          0   _printf_percent.o
+         8          0          0          0          0          0   _printf_percent_end.o
+         8          0          0          0          0          0   _printf_s.o
+        88          0          0          0          0         84   _printf_str.o
+        10          0          0          0          0         60   _sputc.o
+       556          0          0          0          0         80   aeabi_sdivfast.o
+      1076         28          0          0          0        328   daddsub_noclz.o
+        16          4          0          0          0         68   dcheck.o
+        16          4          0          0          0         68   dcheck1.o
+       128          0          0          0          0         84   dcmpin.o
+      1116        272          0          0          0        212   ddiv.o
+       176          4          0          0          0         76   dfix.o
+       136          4          0          0          0         76   dfixu.o
+       100          0          0          0          0        136   dflt_noclz.o
+       136          4          0          0          0         68   dleqf.o
+       476         16          0          0          0        128   dmul.o
+       160          4          0          0          0         68   drleqf.o
+       280          0          0          0          0         92   dunder.o
+        12          0          0          0          0         60   exit.o
+       100          4          0          0          0         68   f2d.o
+        12          4          0          0          0         68   fcheck1.o
+         8          0          0          0          0         68   fpinit.o
+         6          0          0          0          0        132   heapauxi.o
+        14          0          0          0          0          0   libinit.o
+        12          0          0          0          0          0   libinit2.o
+        12          0          0          0          0          0   libshutdown.o
+         6          0          0          0          0          0   libshutdown2.o
+        12          4          0          0         96         68   libspace.o
+        48          4          0          0          0         84   noretval__2sprintf.o
+       116          0          0          0          0         68   retnan.o
+        64          0          0          0          0         68   rt_memclr.o
+        84          0          0          0          0         76   rt_memclr_w.o
+       212          0          0          0          0         68   rt_memcpy.o
+       100          0          0          0          0         80   rt_memcpy_w.o
+         0          0          0          0          0          0   rtentry.o
+        44          4          0          0          0          0   rtentry2.o
+         8          0          0          0          0          0   rtentry4.o
+         4          0          0          0          0          0   rtexit.o
+         8          0          0          0          0          0   rtexit2.o
+        24          8          0          0          0         68   sys_exit.o
+        96          0          0          0          0         80   sys_stackheap_outer.o
+        60          0          0          0          0         68   trapv.o
+         4          0          0          0          0         68   use_no_semi.o
+         0          0          0          0          0          0   usenofp.o
+
+    ----------------------------------------------------------------------
+      5952        380          0          0         96       3300   Library Totals
+        10          0          0          0          0          0   (incl. Padding)
+
+    ----------------------------------------------------------------------
+
+      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   Library Name
+
+      1830         32          0          0         96       1556   c_t.l
+      4112        348          0          0          0       1744   fz_ts.l
+
+    ----------------------------------------------------------------------
+      5952        380          0          0         96       3300   Library Totals
+
+    ----------------------------------------------------------------------
+
+==============================================================================
+
+
+      Code (inc. data)   RO Data    RW Data    ZI Data      Debug   
+
+      9460        588         52        112       3808      12736   Grand Totals
+      9460        588         52        112       3808      12736   ELF Image Totals
+      9460        588         52        112          0          0   ROM Totals
+
+==============================================================================
+
+    Total RO  Size (Code + RO Data)                 9512 (   9.29kB)
+    Total RW  Size (RW Data + ZI Data)              3920 (   3.83kB)
+    Total ROM Size (Code + RO Data + RW Data)       9624 (   9.40kB)
+
+==============================================================================
+

+ 645 - 0
microcontroller/EOM_lock.plg

@@ -0,0 +1,645 @@
+<html>
+<body>
+<pre>
+<h1>µVision3 Build Log</h1>
+<h2>Project:</h2>
+C:\Keil\ARM\Examples\EOM_lock\EOM_lock.uv2
+Project File Date:  07/01/2015
+
+<h2>Output:</h2>
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8472 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8472 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8548 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8540 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(135): error:  #109: expression must have (pointer-to-) function type
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8556 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8556 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8556 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8556 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8556 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8656 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=8656 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(166): warning:  #550-D: variable "step" was set but never used
+Demo.C(170): warning:  #550-D: variable "valid_data" was set but never used
+compiling irq_arm.c...
+linking...
+Program Size: Code=7268 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 3 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(314): warning:  #111-D: statement is unreachable
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(166): warning:  #550-D: variable "step" was set but never used
+Demo.C(170): warning:  #550-D: variable "valid_data" was set but never used
+compiling irq_arm.c...
+linking...
+Program Size: Code=3640 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 4 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(166): warning:  #550-D: variable "step" was set but never used
+Demo.C(170): warning:  #550-D: variable "valid_data" was set but never used
+compiling irq_arm.c...
+linking...
+Program Size: Code=7268 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 3 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(166): warning:  #550-D: variable "step" was set but never used
+Demo.C(170): warning:  #550-D: variable "valid_data" was set but never used
+compiling irq_arm.c...
+linking...
+Program Size: Code=7268 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 3 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(166): warning:  #550-D: variable "step" was set but never used
+Demo.C(170): warning:  #550-D: variable "valid_data" was set but never used
+compiling irq_arm.c...
+linking...
+Program Size: Code=7268 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 3 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(385): error:  #20: identifier "Vout1" is undefined
+Demo.C(386): error:  #65: expected a ";"
+Demo.C(389): error:  #20: identifier "Vout1" is undefined
+Demo.C(424): error:  #20: identifier "Vout1" is undefined
+Demo.C(429): error:  #20: identifier "Vout1" is undefined
+Demo.C(431): error:  #29: expected an expression
+Demo.C(432): error:  #65: expected a ";"
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(387): error:  #65: expected a ";"
+Demo.C(432): error:  #29: expected an expression
+Demo.C(433): error:  #65: expected a ";"
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(432): error:  #29: expected an expression
+Demo.C(433): error:  #65: expected a ";"
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9140 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9124 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(316): error:  #65: expected a ";"
+Demo.C(343): warning:  #12-D: parsing restarts here after previous syntax error
+Demo.C(367): error:  #127: expected a statement
+Demo.C(372): warning:  #111-D: statement is unreachable
+Demo.C(374): error:  #65: expected a ";"
+Demo.C(415): warning:  #12-D: parsing restarts here after previous syntax error
+Demo.C(163): warning:  #177-D: variable "Vout1" was declared but never referenced
+Demo.C(163): warning:  #177-D: variable "Vout2" was declared but never referenced
+Demo.C(167): warning:  #550-D: variable "step" was set but never used
+Demo.C(168): warning:  #177-D: variable "armed" was declared but never referenced
+Demo.C(171): warning:  #550-D: variable "valid_data" was set but never used
+Demo.C(416): error:  #169: expected a declaration
+Demo.C(432): warning:  #12-D: parsing restarts here after previous syntax error
+Demo.C(435): error:  #169: expected a declaration
+Demo.C(486): warning:  #12-D: parsing restarts here after previous syntax error
+Demo.C(488): error:  #79: expected a type specifier
+Demo.C(488): error:  #79: expected a type specifier
+Demo.C(488): warning:  #77-D: this declaration has no storage class or type specifier
+Demo.C(488): error:  #147: declaration is incompatible with "void Write_Digital(int, int)" (declared at line 91)
+Demo.C(489): error:  #77-D: this declaration has no storage class or type specifier
+Demo.C(489): error:  #147: declaration is incompatible with "unsigned char *pbuff" (declared at line 52)
+Demo.C(489): error:  #28: expression must have a constant value
+Demo.C(490): error:  #40: expected an identifier
+Demo.C(490): error:  #18: expected a ")"
+Demo.C(490): error:  #28: expression must have a constant value
+Demo.C(492): error:  #169: expected a declaration
+Demo.C(515): warning:  #12-D: parsing restarts here after previous syntax error
+Demo.C(516): error:  #169: expected a declaration
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9108 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9108 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9108 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9108 RO-data=52 RW-data=108 ZI-data=3812  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(314): warning:  #223-D: function "nanosleep" declared implicitly
+compiling irq_arm.c...
+linking...
+EOM_lock.axf: Error: L6218E: Undefined symbol nanosleep (referred from demo.o).
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(315): warning:  #223-D: function "nanosleep" declared implicitly
+compiling irq_arm.c...
+linking...
+EOM_lock.axf: Error: L6218E: Undefined symbol nanosleep (referred from demo.o).
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(315): warning:  #223-D: function "usleep" declared implicitly
+compiling irq_arm.c...
+linking...
+EOM_lock.axf: Error: L6218E: Undefined symbol usleep (referred from demo.o).
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(314): error:  #29: expected an expression
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(314): error:  #29: expected an expression
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(314): error:  #268: declaration may not appear after executable statement in block
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(44): error:  #147: declaration is incompatible with "short i" (declared at line 22)
+compiling irq_arm.c...
+Target not created
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9176 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9240 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9216 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9216 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9228 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9524 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9528 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9528 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9524 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9544 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9552 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+compiling irq_arm.c...
+linking...
+Program Size: Code=9552 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 0 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.4> may be used before being set
+Demo.C(163): warning: C3017W: <sum.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum.4> may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8176 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 6 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning: C3017W: <sum.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum.4> may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.4> may be used before being set
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8380 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 6 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(163): warning: C3017W: <sum.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum.4> may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.0> may be used before being set
+Demo.C(163): warning: C3017W: <sum_gnd.4> may be used before being set
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8380 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 6 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+Demo.C(163): warning: C3017W: sum_gnd may be used before being set
+Demo.C(163): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8208 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 4 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+Demo.C(163): warning: C3017W: sum_gnd may be used before being set
+Demo.C(163): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8208 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 4 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(164): warning: C3017W: Vout2 may be used before being set
+Demo.C(164): warning: C3017W: Vout1 may be used before being set
+Demo.C(163): warning: C3017W: sum_gnd may be used before being set
+Demo.C(163): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8204 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 4 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8752 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8752 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8752 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8748 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8840 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8840 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8856 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(170): warning: C3017W: armed may be used before being set
+Demo.C(165): warning: C3017W: Vout2 may be used before being set
+Demo.C(165): warning: C3017W: Vout1 may be used before being set
+Demo.C(164): warning: C3017W: sum_gnd may be used before being set
+Demo.C(164): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=8856 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(171): warning: C3017W: armed may be used before being set
+Demo.C(166): warning: C3017W: Vout2 may be used before being set
+Demo.C(166): warning: C3017W: Vout1 may be used before being set
+Demo.C(165): warning: C3017W: sum_gnd may be used before being set
+Demo.C(165): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=9408 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(171): warning: C3017W: armed may be used before being set
+Demo.C(166): warning: C3017W: Vout2 may be used before being set
+Demo.C(166): warning: C3017W: Vout1 may be used before being set
+Demo.C(165): warning: C3017W: sum_gnd may be used before being set
+Demo.C(165): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=9408 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(173): warning: C3017W: armed may be used before being set
+Demo.C(168): warning: C3017W: Vout2 may be used before being set
+Demo.C(168): warning: C3017W: Vout1 may be used before being set
+Demo.C(167): warning: C3017W: sum_gnd may be used before being set
+Demo.C(167): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=9460 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).
+Build target 'Target 1'
+assembling ADuC702x.s...
+compiling Demo.C...
+Demo.C(173): warning: C3017W: armed may be used before being set
+Demo.C(168): warning: C3017W: Vout2 may be used before being set
+Demo.C(168): warning: C3017W: Vout1 may be used before being set
+Demo.C(167): warning: C3017W: sum_gnd may be used before being set
+Demo.C(167): warning: C3017W: sum may be used before being set
+compiling irq_arm.c...
+linking...
+Program Size: Code=9460 RO-data=52 RW-data=112 ZI-data=3808  
+FromELF: creating hex file...
+"EOM_lock.axf" - 0 Error(s), 5 Warning(s).

+ 15 - 0
microcontroller/EOM_lock.sct

@@ -0,0 +1,15 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+LR_IROM1 0x00080000 0x0000F800  {    ; load region size_region
+  ER_IROM1 0x00080000 0x0000F800  {  ; load address = execution address
+   *.o (RESET, +First)
+   *(InRoot$$Sections)
+   .ANY (+RO)
+  }
+  RW_IRAM1 0x00010000 0x00002000  {  ; RW data
+   .ANY (+RW +ZI)
+  }
+}
+

+ 21 - 0
microcontroller/EOM_lock.tra

@@ -0,0 +1,21 @@
+*** Creating Trace Output File 'EOM_lock.tra' Ok.
+### Preparing for ADS-LD.
+### Creating ADS-LD Command Line
+### List of Objects: adding '"aduc702x.o"'
+### List of Objects: adding '"demo.o"'
+### List of Objects: adding '"irq_arm.o"'
+### ADS-LD Command completed:
+--device DARMAD "aduc702x.o" "demo.o" "irq_arm.o" --strict --scatter "EOM_lock.sct" 

+--autoat --summary_stderr --info summarysizes --map --xref --callgraph --symbols 

+--info sizes --info totals --info unused --info veneers 

+ --list ".\EOM_lock.map" -o "EOM_lock.axf"### Preparing Environment (PrepEnvAds)
+### ADS-LD Output File: 'EOM_lock.axf'
+### ADS-LD Command File: 'EOM_lock.lnp'
+### Checking for dirty Components...
+### Creating CmdFile 'EOM_lock.lnp', Handle=0x000003AC
+### Writing '.lnp' file
+### ADS-LD Command file 'EOM_lock.lnp' is ready.
+### ADS-LD: About to start ADS-LD Thread.
+### ADS-LD: executed with 0 errors
+### Updating obj list
+### LDADS_file() completed.

+ 42 - 0
microcontroller/EOM_lock_Opt.Bak

@@ -0,0 +1,42 @@
+### uVision2 Project, (C) Keil Software
+### Do not modify !
+
+ cExt (*.c)
+ aExt (*.s*; *.src; *.a*)
+ oExt (*.obj)
+ lExt (*.lib)
+ tExt (*.txt; *.h; *.inc)
+ pExt (*.plm)
+ CppX (*.cpp)
+ DaveTm { 0,0,0,0,0,0,0,0 }
+
+Target (Target 1), 0x0004 // Tools: 'ARM-ADS'
+GRPOPT 1,(Source Group 1),1,0,0
+
+OPTFFF 1,1,2,0,0,1,1,0,<.\ADuC702x.s><ADuC702x.s> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,75,0,0,0,75,0,0,0,36,6,0,0,44,2,0,0 }
+OPTFFF 1,2,1,654311427,0,171,171,0,<.\Demo.C><Demo.C> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,25,0,0,0,25,0,0,0,102,4,0,0,59,1,0,0 }
+OPTFFF 1,3,1,0,0,0,0,0,<.\irq_arm.c><irq_arm.c> 
+
+ExtF <C:\Keil\ARM\INC\ADI\flash.h> 1,1,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,25,0,0,0,25,0,0,0,121,5,0,0,254,1,0,0 }
+ExtF <C:\Keil\ARM\INC\ADI\ADuC7020.h> 1,1,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,248,255,255,255,226,255,255,255,50,0,0,0,50,0,0,0,146,5,0,0,23,2,0,0 }
+
+TARGOPT 1, (Target 1)
+ ADSCLK=32768
+  OPTTT 1,1,1,0
+  OPTHX 1,65535,0,0,0
+  OPTLX 79,66,8,<.\>
+  OPTOX 16
+  OPTLT 1,1,1,0,1,1,0,1,0,0,0,0
+  OPTXL 1,1,1,1,1,1,1,0,0
+  OPTFL 1,0,1
+  OPTAX 255
+  OPTBL 0,(Data Sheet)<DATASHTS\ADI\ADUC702X_DS.PDF>
+  OPTDL (SARM.DLL)(-cADuC70)(DARMAD.DLL)(-pADuC7020)(SARM.DLL)(-cADuC70)(TARMAD.DLL)(-pADuC7020)
+  OPTDBG 48125,0,()()()()()()()()()() ()()()()
+  OPTKEY 0,(UL2ARM)(-U88308796 -O7 -C0 -FO7 -FD10000 -FC800 -FN1 -FF0ADuC702X -FS080000 -FL0F800)
+  OPTBB 0,0,1,1,0,0,0,0,0,0,<Demo.C>()()
+  OPTDF 0x2
+  OPTLE <>
+  OPTLC <>
+EndOpt
+

+ 17 - 0
microcontroller/EOM_lock_Target 1.dep

@@ -0,0 +1,17 @@
+Dependencies for Project 'EOM_lock', Target 'Target 1': (DO NOT MODIFY !)
+F (.\ADuC702x.s)(0x49B64844)(--device DARMAD --pd "__EVAL SETA 1" -g --apcs=interwork -I "C:\Keil\ARM\INC\ADI" --list "ADuC702x.lst" --xref -o "ADuC702x.o")
+F (.\Demo.C)(0x5D7A2729)(-c --device DARMAD -D__EVAL -g -O3 -Otime --apcs=interwork -I "C:\Keil\ARM\INC\ADI" -o "demo.o" --omf_browse "demo.crf" --depend "demo.d")
+I (C:\Keil\ARM\INC\ADI\ADuC7020.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\irq.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\timer.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\dac.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\uart.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\I2C.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\PLA.H)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\GPIO.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\flash.h)(0x4A02D72A)
+I (C:\Keil\ARM\INC\ADI\pwm.h)(0x4A02D72A)
+I (C:\Keil\ARM\RV31\INC\stdlib.h)(0x4A02D8CA)
+I (C:\Keil\ARM\RV31\INC\stdio.h)(0x4A02D8CA)
+I (C:\Keil\ARM\RV31\INC\string.h)(0x4A02D8CA)
+F (.\irq_arm.c)(0x47A05C22)(-c --device DARMAD -D__EVAL -g -O3 -Otime --apcs=interwork -I "C:\Keil\ARM\INC\ADI" -o "irq_arm.o" --omf_browse "irq_arm.crf" --depend "irq_arm.d")

+ 0 - 0
microcontroller/EOM_lock_Uv2.Bak


BIN
microcontroller/demo.crf


+ 14 - 0
microcontroller/demo.d

@@ -0,0 +1,14 @@
+demo.o: Demo.C
+demo.o: C:\Keil\ARM\INC\ADI\ADuC7020.h
+demo.o: C:\Keil\ARM\INC\ADI\irq.h
+demo.o: C:\Keil\ARM\INC\ADI\timer.h
+demo.o: C:\Keil\ARM\INC\ADI\dac.h
+demo.o: C:\Keil\ARM\INC\ADI\uart.h
+demo.o: C:\Keil\ARM\INC\ADI\I2C.h
+demo.o: C:\Keil\ARM\INC\ADI\PLA.H
+demo.o: C:\Keil\ARM\INC\ADI\GPIO.h
+demo.o: C:\Keil\ARM\INC\ADI\flash.h
+demo.o: C:\Keil\ARM\INC\ADI\pwm.h
+demo.o: C:\Keil\ARM\RV31\INC\stdlib.h
+demo.o: C:\Keil\ARM\RV31\INC\stdio.h
+demo.o: C:\Keil\ARM\RV31\INC\string.h

BIN
microcontroller/demo.o


+ 134 - 0
microcontroller/demo2016_06_05

@@ -0,0 +1,134 @@
+/***************************************************************************
+
+ Author        : ADI - Apps                    www.analog.com/MicroConverter
+
+ Date          : May. 2007
+
+ File          : I2C_Slave.c
+
+ Hardware      : Applicable to ADuC702x rev H or I silicon
+                 Currently targetting ADuC7028.
+
+ Description   : I2C Slave to demonstrate with I2C_Master.
+				 
+				 Operates in two modes, read & write (called recieve and 
+				 transmit here). At the begining of an I2C transmission, the 
+				 Master sends an address. The LSB of this address determines 
+				 if the Master is to read (1) or write (0).
+
+		
+***************************************************************************/
+
+#include<ADuC7028.h>
+
+void My_IRQ_Handler(void);
+
+typedef unsigned char       BYTE;       //8-bit
+typedef unsigned short int  HALFWORD;   //16-bit
+typedef unsigned int        WORD;       //32-bit
+
+
+#define TRUE 1
+#define FALSE 0
+#define HIGH 1
+#define LOW 0
+
+short i = 0, dat[256];
+int r = 0;
+int w = 0;
+
+BYTE i2c_first = TRUE;
+
+
+int main()
+{
+	dat[0] = 0;
+	dat[1] = 1;
+	dat[2] = 2;
+	dat[3] = 3;
+	dat[4] = 4;
+	dat[5] = 5;
+	dat[6] = 6;
+	dat[7] = 7;
+	i=1;
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ=My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x4001;//0x01;		  			// Slave Enable
+	I2C0ID0 = 0xA0;					// Slave ID
+	I2C0STX = 0x77;
+	
+	
+	while (1)
+	{
+	}; 
+
+// 	return 0;
+}
+
+
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+
+unsigned int status;
+unsigned int x;
+unsigned int addr;
+
+
+void My_IRQ_Handler()
+{
+	
+	status = I2C0SSTA;
+	if (((status & 0x02000)==0x02000))   // Slave Transmit IRQ
+	{		 
+		 r=0;
+		 w=-1;
+		 i++;		
+	}
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{
+		if(w==-1){
+	 	   addr = I2C0SRX;
+		   w++;
+		}
+		else{
+		/*	if(w==0){
+
+			}
+			else if(w==1){
+
+			}*/
+			dat[addr+w] = I2C0SRX;
+			w++;
+		} 
+		//I2C0STX = dat[addr+r];
+		//I2C0STX = dat[addr+r];
+		 
+		   //i++;
+	}
+
+	
+	// Slave Transmit
+	if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{		 
+		 I2C0STX = dat[addr+r];
+		 //I2C0STX = dat[addr+r];
+		 r++;
+	//	 i++;		
+	}
+
+	
+	//i++;
+
+
+}
+

+ 156 - 0
microcontroller/i2c_first

@@ -0,0 +1,156 @@
+/***************************************************************************
+
+ Author        : ADI - Apps                    www.analog.com/MicroConverter
+
+ Date          : May. 2007
+
+ File          : I2C_Slave.c
+
+ Hardware      : Applicable to ADuC702x rev H or I silicon
+                 Currently targetting ADuC7028.
+
+ Description   : I2C Slave to demonstrate with I2C_Master.
+				 
+				 Operates in two modes, read & write (called recieve and 
+				 transmit here). At the begining of an I2C transmission, the 
+				 Master sends an address. The LSB of this address determines 
+				 if the Master is to read (1) or write (0).
+
+		
+***************************************************************************/
+
+#include<ADuC7028.h>
+
+void My_IRQ_Handler(void);
+
+typedef unsigned char       BYTE;       //8-bit
+typedef unsigned short int  HALFWORD;   //16-bit
+typedef unsigned int        WORD;       //32-bit
+
+
+#define TRUE 1
+#define FALSE 0
+#define HIGH 1
+#define LOW 0
+
+short i = 0, dat[256], buf = 0;
+int r = 0;
+int w = 0;
+
+BYTE i2c_first = TRUE;
+
+
+int main()
+{
+	dat[0] = 0;
+	dat[1] = 10;
+	dat[2] = 20;
+	dat[3] = 30;
+	dat[4] = 40;
+	dat[5] = 50;
+	dat[6] = 60;
+	dat[7] = 70;
+	i=1;
+
+	// configures GPIO to flash LED P4.2
+	GP4DAT = 0x04000000;			// P4.2 configured as an output. LED is turned on	
+	//GP0CON = 0x00000000;	    // setting IO
+	//GP0DAT = 0x00000000;        // group P0.x as input
+	
+
+	// I2C on P1.0 and P1.1
+ 	GP1CON = 0x22;
+
+	IRQ=My_IRQ_Handler;
+	IRQEN = 0x200;					// I2C0 Slave Interupt
+	
+	I2C0CFG = 0x4001;//0x01;		  			// Slave Enable
+	I2C0ID0 = 0xA0;					// Slave ID
+	I2C0STX = 0x77;
+	
+	
+	while (1)
+	{
+
+	}; 
+
+// 	return 0;
+}
+
+/*short V = -1;
+	
+	DAC1CON = 0x12;	   // AGND-ARef range 0x12 2.5V
+	
+
+
+	DAC1DAT = DATtoADC(V); // output voltage on DAC0
+	//GP4DAT ^= 0x00040000;		// Complement P4.2
+
+	while (1){
+		V = -V;
+		if(V>4096)
+			V = 0;
+		DAC1DAT = DATtoADC(V); // output voltage on DAC0
+	
+		if (Read_Digital(0)==1)
+			GP4DAT ^= 0x00040000;		// Complement P4.2
+
+	   */
+
+/*************************************************/
+/*************************************************/
+/************	IRQ Service Routine  *************/
+/*************************************************/
+/*************************************************/
+
+// If you are using SMB library, try changing the N to a Y in the file /sys/module/i2c_bcm2708/parameters/combined. This worked for me.
+
+
+unsigned int status;
+unsigned int x;
+unsigned int addr;
+unsigned int first=0;
+unsigned step = 0;
+
+
+void My_IRQ_Handler()
+{
+	
+	status = I2C0SSTA;
+		
+	if (((status & 0x0400)==0x0400))   // Stsop test
+	{
+		step = 0;		 		
+	}
+	// Slave Recieve
+	if ((status & 0x08)==0x08)   // Slave Recieve IRQ
+	{
+		//GP4DAT ^= 0x00040000;
+		switch (step){
+			case 0: 
+				addr = I2C0SRX;
+				I2C0FSTA = I2C0FSTA|0x100;
+				I2C0STX = dat[addr];
+				break;
+			case 1: 
+				dat[addr] = I2C0SRX;
+				break;
+			case 2: 
+				dat[addr] += I2C0SRX<<8;
+				break;
+		}
+		step++;
+		
+	}
+
+	
+	// Slave Transmit
+	if ((status & 0x04)==0x04)   // Slave Transmit IRQ
+	{			
+		I2C0STX = dat[addr]>>8;
+		step = 0;				
+	}
+	
+
+}
+

+ 65 - 0
microcontroller/irq_arm.c

@@ -0,0 +1,65 @@
+/*    Function Pointers for Interrupts  */
+typedef void (* tyVctHndlr) (void);
+
+tyVctHndlr    IRQ     = (tyVctHndlr)0x0;
+tyVctHndlr    SWI     = (tyVctHndlr)0x0;
+tyVctHndlr    FIQ     = (tyVctHndlr)0x0;
+tyVctHndlr    UNDEF   = (tyVctHndlr)0x0;
+tyVctHndlr    PABORT  = (tyVctHndlr)0x0;
+tyVctHndlr    DABORT  = (tyVctHndlr)0x0;
+
+void	IRQ_Handler   (void) __irq;
+void	SWI_Handler   (void) __irq;
+void	FIQ_Handler   (void) __irq;
+void	Undef_Handler (void) __irq;
+void	PAbt_Handler  (void) __irq;
+void	DAbt_Handler  (void) __irq;
+
+void	IRQ_Handler(void) __irq		  
+{
+	if ( *IRQ !=0x00)
+	{
+		IRQ();
+	}
+}
+
+void	FIQ_Handler(void) __irq
+{
+	if ( *FIQ !=0x00)
+	{
+		FIQ();
+	}
+}
+
+void	SWI_Handler(void) __irq
+{
+	if ( *SWI !=0x00)
+	{
+		SWI();
+	}
+}
+
+void	Undef_Handler(void)__irq 
+{
+	if ( *UNDEF !=0x00)
+	{
+		UNDEF();
+	}
+}
+
+void	PAbt_Handler(void) __irq
+{
+	if ( *PABORT !=0x00)
+	{
+		PABORT();
+	}
+}
+
+void	DAbt_Handler(void) __irq
+{
+	if ( *DABORT !=0x00)
+	{
+		DABORT();
+	}
+}
+

BIN
microcontroller/irq_arm.crf


+ 1 - 0
microcontroller/irq_arm.d

@@ -0,0 +1 @@
+irq_arm.o: irq_arm.c

BIN
microcontroller/irq_arm.o


+ 436 - 0
pi/ADUCv2p1.py

@@ -0,0 +1,436 @@
+#!/usr/bin/env python
+from smbus import SMBus
+import time
+from struct import*
+import array
+import numpy as np
+
+# instead of having some varisable associated to the class that we should
+# update continuously with the the chip, we only access to the variables
+# to the chip via set_/get_ functions
+
+class ADUCv2p1:
+    # Initialize the connection to the board
+    # addr: i2c addres, can be obtained by running "i2detect -y 1" from terminal
+    # if with_about = True, will print information from the board
+    def __init__(self,addr,with_about=False):
+        self.bus_pi = SMBus(1)
+        self._addr = addr;
+        self.get_wf_len();
+        if with_about==True:
+            print( self.get_text())
+            print( "-----------------\n")
+
+    # Read last valid waveform from the microcontroller, up to 256 points
+    def read_data(self):
+        dat = []
+        if self._wf_len>=256:
+            N=16
+            self._wf_len = 256
+        else:
+            N = int(self._wf_len/16+1)
+            ## add an error message in case wf_len/16 is not an integer?
+
+        self.set_transf(1)# to remove    
+        for i in range(0,N):
+            block = self.bus_pi.read_i2c_block_data(self._addr,i,32)
+            buff = pack("32B",*block)
+            dat = np.append(dat,unpack("<16H",buff))
+        self.set_transf(0) #to remove   
+        
+        dat=np.uint16(dat)
+        return dat[0:self._wf_len]
+
+    # 
+    def get_text(self):
+        dat = []        
+        for i in range(0,16):
+            block = self.bus_pi.read_i2c_block_data(self._addr,i+50,32)
+            buff = pack("32B",*block)
+            dat = np.append(dat,unpack("32c",buff))        
+        return ''.join(dat.astype(str))#''.join(str((dat[0:3]).tostring()))
+
+    # sets DACX where X is the channel ch to the voltage V (in the range 0 to 4095)
+    # Make sure you are in a mode where the voltage is not being inmediately overwritten
+    def set_Vout(self,ch,V):
+        self.bus_pi.write_word_data(self._addr,100+ch,V)
+        #execute the setting commande on the chip
+        self.bus_pi.read_i2c_block_data(self._addr,105,1)
+        return 
+
+    def get_Vout(self,ch):
+        #execute the reading commande on the chip
+        self.bus_pi.read_i2c_block_data(self._addr,104,1)
+        block = self.bus_pi.read_i2c_block_data(self._addr,100+ch,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the input offset (in the range 0 to 4095)
+    def set_offset(self, V):
+        set_Vout(0, V)
+
+    def get_offset(self):
+        return get_Vout(0)
+
+    # sets the value of the coarse output voltage when the box is in learn mode
+    def set_Vlearn(self,V):
+        self.bus_pi.write_word_data(self._addr,110,V)
+        return 
+
+    def get_Vlearn(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,110,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # reads the height of the last measured signal
+    def get_Vin(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,111,8)
+        buff = pack("8B",*block)
+        dat = unpack("<d",buff)   
+        dat=np.float64(dat)
+        return dat[0]
+
+    # reads the height of the last measured ground
+    def get_Vin_gnd(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,112,8)
+        buff = pack("8B",*block)
+        dat = unpack("<d",buff)   
+        dat=np.float64(dat)
+        return dat[0]
+
+    # 
+    def get_ID(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,120,1)
+        self._addr = block[0]
+        return block[0]>>1
+
+    def set_ID(self,ID):
+        self._addr = ID
+        return self.bus_pi.write_byte_data(self._addr,120,ID<<1)
+
+    # 
+    def get_channel(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,121,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    def set_channel(self,channel):
+        return self.bus_pi.write_word_data(self._addr,121,channel)
+
+    # 
+    def set_transf(self,status):
+        return self.bus_pi.write_byte_data(self._addr,122,status)
+
+
+    # Sets the remote_trigg flag. Set to 0 so that the microcontroller uses the trigger
+    # input, set it to 1 so that it continuously triggers
+    def set_remote_trigg(self,status):
+        return self.bus_pi.write_byte_data(self._addr,115,status)
+
+    def get_remote_trigg(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,115,1)
+        self._addr = block[0]
+        return block[0]
+
+    # Sets the number of recorded points, up to a maximum of 256. Sampling frequency is approx. 1MHz.
+    def set_wf_len(self,wf_len):
+        self._wf_len = wf_len
+        if wf_len>256:
+            print( "sorry, it is not possible to have more than 256 point per waveform.\n")
+            self._wf_len = 256
+        return self.bus_pi.write_word_data(self._addr,123,self._wf_len)
+
+    def get_wf_len(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,123,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        self._wf_len = dat[0]
+        return dat[0]
+
+    #
+    def get_trigg_cnt(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,124,4)
+        buff = pack("4B",*block)
+        dat = unpack("<I",buff)   
+        dat=np.uint32(dat)
+        return dat[0]
+
+    #
+    def get_wf_cnt(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,113,8)
+        buff = pack("8B",*block)
+        dat = unpack("<I",buff)   
+        dat=np.uint32(dat)
+        return dat[0]
+
+    #
+    def get_v_cnt(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,114,8)
+        buff = pack("8B",*block)
+        dat = unpack("<I",buff)   
+        dat=np.uint32(dat)
+        return dat[0]
+
+    # 
+    def set_test(self,tmp):
+        self.bus_pi.write_word_data(self._addr,141,tmp)
+        self.bus_pi.read_i2c_block_data(self._addr,105,1)
+        return
+
+    def get_test(self):
+        self.bus_pi.read_i2c_block_data(self._addr,104,1)
+        block = self.bus_pi.read_i2c_block_data(self._addr,141,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    #     
+    def set_erase(self):
+        #self.bus_pi.read_i2c_block_data(self._addr,106,1)
+        self.bus_pi.write_byte_data(self._addr,106,0)
+        time.sleep(0.04)
+
+        return
+    
+    #
+    def get_probe(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,142,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    #
+    def set_probe(self,tmp):
+        self.bus_pi.write_word_data(self._addr,142,tmp)
+        return
+        
+    # Set the value we are aiming to achieve in the signal when in lock mode 
+    def set_Vset(self,Vset):
+        return self.bus_pi.write_word_data(self._addr,125,Vset)
+
+    def get_Vset(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,125,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the number of waveforms to average before stabilizing
+    def set_N(self,N):
+        return self.bus_pi.write_word_data(self._addr,126,N)
+
+    def get_N(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,126,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # 
+    def get_FEE_addr(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,140,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    def set_FEE_addr(self,FEE_addr):
+        return self.bus_pi.write_word_data(self._addr,140,FEE_addr)
+
+    # Set the point at which we start measuring the signal
+    def set_start(self,start):
+        return self.bus_pi.write_word_data(self._addr,127,start)
+
+    def get_start(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,127,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the point at which we stop measuring the signal
+    def get_stop(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,128,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    def set_stop(self,stop):
+        return self.bus_pi.write_word_data(self._addr,128,stop)
+
+    # Set the point at which we start measuring the background
+    def set_start_gnd(self,start_gnd):
+        return self.bus_pi.write_word_data(self._addr,131,start_gnd)
+    
+    def get_start_gnd(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,131,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the point at which we stop measuring the background
+    def set_stop_gnd(self,stop_gnd):
+        return self.bus_pi.write_word_data(self._addr,132,stop_gnd)
+
+    def get_stop_gnd(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,132,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set whether the microcontroller should automatically select the best offset
+    # and gain when in learn mode. auto_set_pga=0 to turn off the functionality and
+    # to do it manually using set_pga and set_Vout(0, x)
+    def set_auto_set_pga(self,auto_set_pga):
+        return self.bus_pi.write_word_data(self._addr,129,auto_set_pga)
+
+    def get_auto_set_pga(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,129,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the ratio of sensitivities of the fine to coarse voltage outputs of the board
+    # This is 20 as per circuit design, but can be tuned more precisely
+    def set_coarse_fine_ratio(self,coarse_fine_ratio):
+        return self.bus_pi.write_word_data(self._addr,130,coarse_fine_ratio)
+
+    def get_coarse_fine_ratio(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,130,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set whether the microcontroller should subtract the background when measuring.
+    # status=0 to disable this. status=1 to enable it.
+    def set_enab_gnd(self,status):
+        return self.bus_pi.write_byte_data(self._addr,133,status)
+
+    def get_enab_gnd(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,133,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+    
+    # Set the pga_state, this is defined via state = g*16+8 where g is such that the gain G
+    # in the input measurements is G=2^g and G is one of {1, 2, 4, 8, 16, 32, 64, 128}
+    # i.e. 0<g<7
+    def set_pga_state(self,state):
+        self.bus_pi.write_byte_data(self._addr,136,state)
+        #execute set on the chip
+        self.bus_pi.read_i2c_block_data(self._addr,137,1)
+        return
+
+    def get_pga_state(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,136,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+    
+    def read_pga_state(self):
+        #execute set on the chip
+        self.bus_pi.read_i2c_block_data(self._addr,138,1)
+        return 
+
+    def set_input_gain(self, gain):
+        state = int(math.log2(gain))*16 + 8
+        self.set_pga_state(self, state)
+
+    def get_input_gain(self):
+        state = self.read_pga_state(self)
+        return (state-8)//16
+
+    # Set the feedback gain
+    def set_Gain(self,Gain):
+        tmp = (Gain)
+        buff = pack("<f",Gain)
+        #print buff
+        dat = unpack("4B",buff)
+        #print dat
+        return self.bus_pi.write_i2c_block_data(self._addr,134,[dat[0],dat[1],dat[2],dat[3]])
+
+    def get_Gain(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,134,4)
+        #print block
+        buff = pack("4B",*block)
+        dat = unpack("<f",buff)   
+        dat=np.float32(dat)
+        return dat[0]
+
+    # Set the maximum step step_max, allowed in one iteration of the loop
+    def set_step_max(self,step_max):
+        return self.bus_pi.write_word_data(self._addr,135,step_max)
+
+    def get_step_max(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,135,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Read whether we are in learn (0) or lock mode (1)
+    def get_mode(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,139,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Set the relative sensitivities of the coarse and fine output
+    def set_coarse_fine_ratio(self,status):
+        return self.bus_pi.write_byte_data(self._addr,140,status)
+
+    def get_coarse_fine_ratio(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,140,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+    # Read whether we are out of lock
+    def get_mode(self):
+        block = self.bus_pi.read_i2c_block_data(self._addr,141,2)
+        buff = pack("2B",*block)
+        dat = unpack("<H",buff)   
+        dat=np.uint16(dat)
+        return dat[0]
+
+
+    # Debugging
+    def read_all_param(self):
+        print( "start = %d" %self.get_start())
+        print( "stop = %d" %self.get_stop())
+        print( "Vset = %d" %self.get_Vset())
+        print( "wf_len = %d" %self.get_wf_len())
+        print ("step = %d" %self.get_step())
+        print( "N = %d" %self.get_N())
+        print( "Channel = %d" %self.get_channel())
+        print( "ID = %d" %self.get_ID())
+    
+
+    '''def set_test_all_param(self):
+        self.set_start(0)
+        self.set_stop(10)
+        self.set_Vset(20)
+        self.set_wf_len(30)
+        self.set_step(40)
+        self.set_N(60)'''
+
+
+

+ 14 - 0
pi/Vout_carac.py

@@ -0,0 +1,14 @@
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+
+from ADUCv2p0 import*
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+
+chip1.set_Vout(1,1010)
+chip1.set_Vout(2,1011) 

BIN
pi/__pycache__/ADUCv2p1.cpython-35.pyc


+ 46 - 0
pi/accuracy_vs_noise.py

@@ -0,0 +1,46 @@
+"""
+evaluation of the standard deviation for different numbers of point
+if the noise is such that we have sigma as a standard deviations
+then averaging N points should give a std of sigma/N**0.5
+"""
+
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+
+from ADUCv2p0 import*
+
+
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+chip1.set_remote_trigg(1)
+
+chip1.set_pga_state(0x18)
+
+chip1.set_Vout(0,800)
+
+Nwf = 100
+
+dat1 = np.zeros(Nwf)
+dat10 = np.zeros(Nwf)
+dat100 = np.zeros(Nwf)
+
+for k in range(0,Nwf):
+    data = chip1.read_data()
+    dat1[k] = data[50]
+    dat10[k] = np.mean(data[50:60])
+    dat100[k] = np.mean(data[50:150])
+    print(k)
+    
+print(np.std(dat1))
+print(np.std(dat10))
+print(np.std(dat100))
+
+

+ 2 - 0
pi/data/long_term.csv

@@ -0,0 +1,2 @@
+2,1568327594.92623,3,4,5,6,7,8,9,10,11
+3,1568327595.92623,3,4,5,6,7,8,9,10,11

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
pi/data/waveforms/233.csv


BIN
pi/drift.npy


BIN
pi/drift2.npy


BIN
pi/drift3.npy


+ 79 - 0
pi/fit_gain.py

@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+#from smbus import SMBus
+import time
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+
+from ADUCv2p0 import*
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+chip1.set_auto_set_pga(1)
+chip1.set_Vout(0,2500)  #DAC for offset
+chip1.set_pga_state(0x08)
+#chip1.set_pga_state(0x18) #G=2
+#chip1.set_pga_state(0x28) #G=4
+#chip1.set_pga_state(0x38) #G=8
+#chip1.set_pga_state(0x48) #G=16
+#chip1.set_pga_state(0x58) #G=32
+#chip1.set_pga_state(0x68) #G=64
+#chip1.set_pga_state(0x78)
+
+chip1.set_Vlearn(3200)
+chip1.set_start(20)
+chip1.set_stop(100)
+chip1.set_start_gnd(125)
+chip1.set_stop_gnd(200)
+chip1.set_wf_len(200)
+chip1.set_enab_gnd(1)
+chip1.set_N(1)
+chip1.set_Gain(20)
+chip1.set_remote_trigg(0)
+
+chip1.set_Vout(2, 4000)
+time.sleep(2) #Let auto_set_pga do its job
+chip1.set_auto_set_pga(0) #Stop it while we scan
+print(chip1.get_auto_set_pga())
+print(chip1.get_Vout(0))
+print(chip1.get_pga_state())
+print('---')
+time.sleep(2)
+
+
+
+
+npt = chip1.get_wf_len()
+start = chip1.get_start()
+stop = chip1.get_stop()
+start_gnd = chip1.get_start_gnd()
+stop_gnd = chip1.get_stop_gnd()
+
+
+data = chip1.read_data()
+t = np.linspace(0,npt,npt)
+
+
+measurements = []
+for Vfine in range(2000, 4000, 100):
+    chip1.set_Vout(2, Vfine)
+    time.sleep(0.1)
+    data = chip1.read_data()
+    gnd = sum(data[start_gnd:stop_gnd])/(stop_gnd-start_gnd)
+    signal = sum(data[start:stop])/(stop-start)
+    print(chip1.get_Vout(2), signal-gnd)
+    measurements.append([chip1.get_Vout(2), signal-gnd])
+    
+measurements = np.array(measurements)
+p = np.polyfit(measurements[:,0], measurements[:,1], deg=1)
+print('signal-gnd vs Vfine slope', p[0])
+chip1.set_Gain(1/p[0]*.9)
+print('Gain has been set to 90%*1/slope', 1/p[0]*.9)
+
+

+ 40 - 0
pi/long_term_drift.py

@@ -0,0 +1,40 @@
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+
+from ADUCv2p0 import*
+
+
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+chip1.set_remote_trigg(1)
+
+chip1.set_pga_state(0x78)
+
+chip1.set_Vout(0,790)
+
+Nwf = 120*10
+
+dat = np.zeros(Nwf)
+
+
+for k in range(0,Nwf):
+    data = chip1.read_data()
+    dat[k] = np.mean(data)
+    time.sleep(30)
+    print(k,dat[k])
+    np.save("drift3",dat)
+    
+
+
+plt.plot(dat)
+plt.show()
+
+

+ 12 - 0
pi/long_term_drift_analysis.py

@@ -0,0 +1,12 @@
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+from scipy import stats
+
+dat = np.load("drift.npy")
+
+plt.plot(dat)
+plt.show()

+ 155 - 0
pi/oscillo_charac2.py

@@ -0,0 +1,155 @@
+import time
+from struct import *
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+
+from ADUCv2p1 import *
+
+
+chip1 = ADUCv2p1(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+chip1.set_auto_set_pga(1)
+chip1.set_Vout(0,2500)  #DAC for offset, 2000 at channel 1
+#chip1.set_pga_state(0x08)
+#chip1.set_pga_state(0x18) #G=2
+#chip1.set_pga_state(0x28) #G=4
+#chip1.set_pga_state(0x38) #G=8
+#chip1.set_pga_state(0x48) #G=16
+#chip1.set_pga_state(0x58) #G=32
+#chip1.set_pga_state(0x68) #G=64
+#chip1.set_pga_state(0x78)
+chip1.set_Vlearn(3250)
+chip1.set_start(25)
+chip1.set_stop(85)
+chip1.set_start_gnd(110)
+chip1.set_stop_gnd(140)
+chip1.set_wf_len(140)
+chip1.set_enab_gnd(1)
+chip1.set_N(1)
+chip1.set_Gain(11)
+chip1.set_remote_trigg(0)
+chip1.set_step_max(200)
+
+time.sleep(2)
+#chip1.set_auto_set_pga(0)
+print(chip1.get_auto_set_pga())
+print(chip1.get_Vout(0))
+print(chip1.get_pga_state())
+print('---')
+time.sleep(2)
+
+#print chip1.get_Vset()*0.61
+#print chip1.get_trigg_cnt()
+
+
+#chip1.set_Vout(0,1500)
+npt = chip1.get_wf_len()
+
+start = chip1.get_start()
+stop = chip1.get_stop()
+start_gnd = chip1.get_start_gnd()
+stop_gnd = chip1.get_stop_gnd()
+
+
+#print npt
+    #print "start"
+data = chip1.read_data()
+    #print "stop"
+#plt.plot(data)
+#plt.show()
+
+t = np.linspace(0,npt,npt)
+
+fig, ax = plt.subplots(1, 1)
+    #ax.set_aspect('equal')
+    #ax.set_xlim(0, 255)
+    #ax.set_ylim(0, 255)
+    #ax.hold(True)
+    #rw = randomwalk()
+    #x, y = rw.next()
+
+doblit = True
+plt.show(False)
+plt.draw()
+
+if doblit:
+    # cache the background
+    background = fig.canvas.copy_from_bbox(ax.bbox)
+
+gnd = sum(data[start_gnd:stop_gnd])/(stop_gnd-start_gnd)
+
+points = ax.plot(t,data.astype(int),".")[0]
+#points = ax.hist(data.astype(int))[0]
+##ax.axvline(start)
+##ax.axvline(stop)
+##
+##ax.axvline(start_gnd,color='red')
+##ax.axvline(stop_gnd,color='red')
+
+tic = time.time()
+###
+niter = 60000
+###
+
+std = 0
+ave = np.zeros(niter,dtype = np.float)
+
+#fig.canvas.draw()
+total_data = np.zeros_like(data,dtype = np.float)
+print(len(total_data))
+print(chip1.get_Gain())
+
+measurements = []
+
+for ii in range(niter):
+    #chip1.set_remote_trigg(1)
+        # update the xy data
+    data = chip1.read_data()
+    #print total_data
+        #total_data += data
+        #points.set_data(t,total_data/(ii+1.0))
+    gnd = sum(data[start_gnd:stop_gnd])/(stop_gnd-start_gnd)
+    signal = sum(data[start:stop])/(stop-start)
+    measurements.append(signal-gnd)
+    
+    print(chip1.get_Vout(1), chip1.get_Vout(2), signal, gnd, signal-gnd, np.std(data[start:stop]), np.std(data[start_gnd:stop_gnd]))
+    print(np.std(measurements), chip1.get_Vout(0), chip1.get_pga_state())
+    points.set_data(t,data.astype(int))
+#    points.set_data(data.astype(int))
+
+
+    #ave[ii]=np.mean(data[50::])
+    
+    av = np.mean(data)
+    #for k in range(0,npt):
+        #if abs(data[k]-av)>0.02*av:
+            #data[k]=av
+
+    points.set_data(t,data.astype(int))
+    std = np.std(data)
+    #print(std)
+    #print(max(data)-min(data))
+    #print(av)
+    
+    if doblit:
+            # restore background
+        fig.canvas.restore_region(background)
+
+            # redraw just the points
+        ax.draw_artist(points)
+
+            # fill in the axes rectangle
+        fig.canvas.blit(ax.bbox)
+
+    else:
+            # redraw everything
+        fig.canvas.draw()
+        
+    time.sleep(10)
+
+
+

+ 13 - 0
pi/read_scan.py

@@ -0,0 +1,13 @@
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+
+ADC = np.load("scan_data_ag2.npy")
+
+for g in range(1,8):
+    plt.plot(ADC[g-1])
+    
+plt.show()

+ 41 - 0
pi/scan.py

@@ -0,0 +1,41 @@
+""" scan the offset for each gain and save the data """
+
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+
+from ADUCv2p0 import*
+
+
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+chip1.set_remote_trigg(1)
+
+ADC = np.zeros((7,1000))
+
+
+
+chip1.set_pga_state(0x18)
+for g in range(1,8):
+    chip1.set_pga_state(16*g+8)
+
+    for k in range(0,1000):
+
+        chip1.set_Vout(0,k*4)
+        time.sleep(0.05)
+        data = chip1.read_data()
+        ADC[g-1,k] = np.mean(data)
+        print(g,k,np.mean(data))
+    
+    plt.plot(ADC[g-1])
+
+np.save("tmp",ADC)
+
+plt.show()

+ 59 - 0
pi/scan_analysis.py

@@ -0,0 +1,59 @@
+"""
+evaluate the offset for the various gains
+"""
+
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+from scipy import stats
+
+ADC = np.load("tmp.npy")
+V = np.linspace(0,990,1000)
+slope = np.zeros(7)
+
+for g in range(1,8):
+    k=0
+    while ADC[g-1,k]<10:
+        k+=1
+    start = k
+    while (k<1000 and ADC[g-1,k]<4000):
+        k+=1
+    stop = k
+    slope[g-1], intercept,t_value,p_value,std_err = stats.linregress(V[start:stop],ADC[g-1,start:stop])
+    plt.plot(V[start:stop],ADC[g-1,start:stop])
+    plt.plot(V,slope[g-1]*V+intercept,':',color='black')
+    print(slope[g-1])
+    print(intercept)
+    
+plt.ylim(-10,4100)
+plt.xlim(-1,810)
+plt.xlabel("Voffset")
+plt.ylabel("ADC")
+plt.title("Gain from 2 to 128")
+plt.grid()
+plt.show()
+
+G = [1.63/0.62,3.044/1.63,4.66/3.044,6.15/4.66,7.24/6.15,7.926/7.24]
+Gth = [3,7.0/3,15.0/7,31.0/15,63/31,127/63]
+B=slope
+
+for g in range(2,8):
+    G[g-2] = slope[g-1]/slope[g-2]
+
+for g in range(1,8):
+    B[g-1]=slope[g-1]/(2**g-1)
+
+plt.plot(G)
+plt.plot(Gth)
+plt.show()
+
+plt.plot(B)
+plt.xlabel("Gain G from 2 to 128")
+plt.ylabel("B")
+#plt.title("Gain from 2 to 128")
+plt.grid()
+
+plt.show()

BIN
pi/scan_data.npy


BIN
pi/scan_data_ag.npy


BIN
pi/scan_data_ag2.npy


BIN
pi/scan_data_new_R.npy


BIN
pi/scan_data_new_R_HR.npy


+ 40 - 0
pi/scan_gain_in.py

@@ -0,0 +1,40 @@
+"""
+evaluation of the gains: measure the peak-to-peak of the input signal
+for the various gains
+It supposes an input pulse (and trigger signal)
+
+
+"""
+
+from struct import*
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+import time
+
+from ADUCv2p0 import*
+
+
+chip1 = ADUCv2p0(0x50,True)
+
+chip1.set_channel(3) #ADC
+
+#chip1.set_remote_trigg(1)
+
+Vpp = np.zeros(7)
+
+
+
+chip1.set_pga_state(0x18)
+for g in range(1,8):
+    chip1.set_pga_state(16*g+8)
+    time.sleep(0.5)
+    data = chip1.read_data()
+    Vpp[g-1] = max(data)-min(data)
+    
+plt.plot(Vpp,'o')
+
+plt.yscale("log")
+
+plt.show()

+ 414 - 0
pi/server.py

@@ -0,0 +1,414 @@
+import time
+from struct import *
+import ctypes
+import array
+import numpy as np
+import matplotlib.pyplot as plt
+
+import eel # GUI
+
+#from ADUCv2p1 import * # TO DO
+
+###################################
+## PYTHON UTILITIES
+###################################
+last_wf_number = -1;
+last_timestamp = 0
+def save_waveform():
+	chip = chips[state["selected_board"]]
+	data = chip.read_data()
+	gnd = sum(data[state["start_gnd"]:state["stop_gnd"]])/(state["stop_gnd"]-state["start_gnd"])
+	signal = sum(data[state["start"]:state["stop"]])/(state["stop"]-state["start"])
+	gnd_std = np.std(data[state["start_gnd"]:state["stop_gnd"]])
+	signal_std = np.std(data[state["start"]:state["stop"]])
+	wf_number = chip.get_wf_cnt()
+	if(last_wf_number>0):
+		state["board_freq"] = (timestamp - last_timestamp)/(wf_number - last_wf_number)
+	last_wf_number, last_timestamp = wf_number, timestamp
+	timestamp = time.time()
+	tosave = [wf_number, timestamp, state["start"], state["stop"], state["start_gnd"], state["stop_gnd"], state["input_gain"], state["offset"], signal, gnd, signal_std, gnd_std, state["wf_len"]] + list(data)
+	np.savetxt("data/waveforms/"+str(int(timestamp*100))+".csv", [tosave], delimiter=",", fmt='%10.5f')
+	# Save more data for long term graphs
+	tosave = [wf_number, timestamp, signal, gnd, signal-gnd, signal_std, gnd_std, chip.get_mode(), chip.get_out_of_lock(), chip.getVout(1), chip.getVout(2)]
+	line = '\n'+','.join(map(str, tosave))
+	with open('data/long_term.csv','a') as fd:
+		fd.write(line)
+
+import datetime
+def clean_old_files():
+	for dirpath, dirnames, filenames in os.walk("data/waveforms/"):
+		for file in filenames:
+			curpath = os.path.join(dirpath, file)
+			file_modified = datetime.datetime.fromtimestamp(os.path.getmtime(curpath))
+			if datetime.datetime.now() - file_modified > datetime.timedelta(hours=10):
+				os.remove(curpath)
+
+@eel.expose
+def calibrate_gain():
+	chip = chips[state["selected_board"]]
+	auto_set_pga = state["auto_set_pga"]
+	chip.set_auto_set_pga(0) #Stop it while we scan
+
+	measurements = []
+	for Vfine in range(2000, 4000, 100):
+		chip.set_Vout(2, Vfine)
+		time.sleep(0.1)
+		data = chip.read_data()
+		gnd = sum(data[state["start_gnd"]:state["stop_gnd"]])/(state["stop_gnd"]-state["start_gnd"])
+		signal = sum(data[state["start"]:state["stop"]])/(state["stop"]-state["start"])
+		print('Vfine', chip.get_Vout(2), 'signal', signal-gnd)
+		measurements.append([chip.get_Vout(2), signal-gnd])
+	chip.set_Vout(2, 3000)
+	
+	measurements = np.array(measurements)
+	p = np.polyfit(measurements[:,0], measurements[:,1], deg=1)
+	print('signal-gnd vs Vfine slope', p[0])
+	chip.set_Gain(1/p[0])
+	print('Gain has been set to 1/slope', 1/p[0])
+
+	plt.plot(np.arange(2000, 4000, 100), measurements)
+	plt.plot(np.range(2000, 4000, 100), np.range(2000, 4000, 100)*p[0] + p[1])
+	plt.show()
+
+	chip.set_auto_set_pga(auto_set_pga)
+	update_state()
+
+@eel.expose
+def calibrate_coarse_fine_ratio():
+	chip = chips[state["selected_board"]]
+	auto_set_pga = state["auto_set_pga"]
+	chip.set_auto_set_pga(0) #Stop it while we scan
+
+	# Scan Vfine
+	measurements = []
+	for Vfine in range(2500, 3500, 100):
+		chip.set_Vout(2, Vfine)
+		time.sleep(0.1)
+		data = chip.read_data()
+		gnd = sum(data[state["start_gnd"]:state["stop_gnd"]])/(state["stop_gnd"]-state["start_gnd"])
+		signal = sum(data[state["start"]:state["stop"]])/(state["stop"]-state["start"])
+		print('Vfine', chip.get_Vout(2), 'signal', signal-gnd)
+		measurements.append([chip.get_Vout(2), signal-gnd])
+	chip.set_Vout(2, 3000)
+	measurements = np.array(measurements)
+	p = np.polyfit(measurements[:,0], measurements[:,1], deg=1)
+	# Scan Vcoarse
+	measurements = []
+	low, high = state["Vlearn"]-100, state["Vlearn"]+100
+	if(low<0):
+		low=0
+	if(high>4000):
+	 high=4000
+	for Vcoarse in range(low, high, 20):
+		chip.set_Vlearn(Vcoarse)
+		time.sleep(0.1)
+		data = chip.read_data()
+		gnd = sum(data[state["start_gnd"]:state["stop_gnd"]])/(state["stop_gnd"]-state["start_gnd"])
+		signal = sum(data[state["start"]:state["stop"]])/(state["stop"]-state["start"])
+		print('Vcoarse', chip.get_Vlearn(), 'signal', signal-gnd)
+		measurements.append([chip.get_Vlearn(), signal-gnd])
+	chip.set_Vlearn(state["Vlearn"])
+	measurements = np.array(measurements)
+	q = np.polyfit(measurements[:,0], measurements[:,1], deg=1)
+	# Set to ratio
+	chip.set_coarse_fine_ratio(q[0]/p[0])
+
+	chip.set_auto_set_pga(auto_set_pga)
+	update_state()
+
+
+###################################
+## EXPOSED GUI COMMUNICATION
+###################################
+
+# Graphs
+from os import listdir
+@eel.expose
+def listFiles(path):
+	return listdir(path)
+@eel.expose
+def loadFile(path):
+	return list(np.loadtxt(path, delimiter=","))
+@eel.expose
+def loadLongTerm():
+	li = list(np.loadtxt('data/long_term.csv', delimiter=","))
+	if((li[-1][1]-li[0][1])/60/60 > 24 or len(li)>100000): # Time to clean up, delete until we have less than 90000 points and 20 hours of data
+		with open('data/long_term.csv') as f, open("data/long_term_tmp.csv", "w") as out:
+			for x in range(len(li)):
+				if(len(li)-x>90000 or (li[-1][1]-li[x][1])/60/60 > 20):
+					next(f)
+			for line in f:
+				out.write(line)
+			os.remove("data/long_term.csv")
+			os.rename("data/long_term_tmp.csv", "data/long_term.csv")
+	return [list(l) for l in li]
+
+# Expose functions to GUI and do some parameter checking
+def error(txt):
+	eel.error(txt)
+def warning(txt):
+	eel.warning(txt)
+
+@eel.expose
+def set_selected_board(n):
+	if n>len(chips):
+		error("Selected board does not exist.")
+		return;
+	state["selected_board"] = n
+	update_state()
+@eel.expose
+def set_pi_freq(freq):
+	if(freq>100):
+		error("The communication cannot be this fast. High values are likely to disturb the board.")
+		return
+	if(freq<0.2):
+		error("Frequency must be at least 0.2Hz.")
+		return
+	if(freq>10):
+		warning("High values are likely to disturb the board.")
+	state["pi_freq"] = freq
+	eel.renderUI(state)
+@eel.expose
+def set_remote_trigg(status):
+	status = int(status)
+	if status not in [0, 1]:
+		error("remote_trigg must be set to either 0 or 1.")
+		return
+	return chips[state["selected_board"]].set_remote_trigg(status)
+	update_state()
+@eel.expose
+def set_enab_gnd(status):
+	status = int(status)
+	if status not in [0, 1]:
+		error("enab_gnd must be set to either 0 or 1.")
+		return
+	return chips[state["selected_board"]].set_enab_gnd(status)
+	update_state()
+@eel.expose
+def set_Vlearn(Vlearn):
+	if Vlearn>4095 or Vlearn<0: 
+		error("Vlearn must be in the range 0-4095")
+		return
+	if Vlearn<2000: 
+		warning("Low values of Vlearn will heavily attenuate the output. See the response curve.")
+	if Vlearn>3500: 
+		warning("High values of Vlearn may not leave enough room for the stabilization process and may result in the board going out of loop. See the response curve.")
+	return chips[state["selected_board"]].set_Vlearn(Vlearn)
+	update_state()
+@eel.expose
+def set_start(start):
+	if start>255 or start<0: 
+		error("start must be in the range 0-256")
+		return
+	if start>state["stop"]: 
+		error("start must be lower than stop")
+		return
+	if start>state["wf_len"]: 
+		error("start must be lower than the waveform length")
+		return
+	return chips[state["selected_board"]].set_start(start)
+	update_state()
+@eel.expose
+def set_stop(stop):
+	if stop>255 or stop<0: 
+		error("stop must be in the range 0-256")
+		return
+	if stop<state["start"]: 
+		error("start must be lower than stop")
+		return
+	if stop>state["wf_len"]: 
+		error("stop must be lower than the waveform length")
+		return
+	return chips[state["selected_board"]].set_stop(stop)
+	update_state()
+@eel.expose
+def set_start_gnd(start_gnd):
+	if start_gnd>255 or start_gnd<0: 
+		error("start_gnd must be in the range 0-256")
+		return
+	if start_gnd>state["stop_gnd"]: 
+		error("start_gnd must be lower than stop")
+		return
+	if start_gnd>state["wf_len"]: 
+		error("start_gnd must be lower than the waveform length")
+		return
+	return chips[state["selected_board"]].set_start_gnd(start_gnd)
+	update_state()
+@eel.expose
+def set_stop_gnd(stop_gnd):
+	if stop_gnd>255 or stop_gnd<0: 
+		error("stop_gnd must be in the range 0-256")
+		return
+	if stop_gnd<state["start_gnd"]: 
+		error("start must be lower than stop")
+		return
+	if stop_gnd>state["wf_len"]: 
+		error("stop_gnd must be lower than the waveform length")
+		return
+	return chips[state["selected_board"]].set_stop_gnd(stop_gnd)
+	update_state()
+@eel.expose
+def set_wf_len(*params):
+	if wf_len>255 or wf_len<0: 
+		error("wf_len must be in the range 0-256")
+		return
+	if wf_len<state["stop"] or wf_len<state["stop_gnd"]: 
+		error("wf_len must be higher than both stop and stop_gnd")
+		return
+	return chips[state["selected_board"]].set_wf_len(*params)
+	update_state()
+@eel.expose
+def set_N(N):
+	N = int(N)
+	if N > 5:
+		warning("Note that increasing the Number of waveforms per stabilization loop decreases the speed of the stabilization. We typically just have N=1.")
+	return chips[state["selected_board"]].set_N(N)
+	update_state()
+@eel.expose
+def set_step_max(step):
+	if step>4095 or step<1: 
+		error("step_max must be in the range 0-1")
+		return
+	if step<50:
+		warning("step_max seems low. This may limit the ability to react to fast power fluctuations.")
+	return chips[state["selected_board"]].set_step_max(step)
+	update_state()
+@eel.expose
+def set_Gain(*params):
+	return chips[state["selected_board"]].set_Gain(*params)
+	update_state()
+@eel.expose
+def set_auto_set_pga(status):
+	if status not in [0, 1]:
+		error("auto_set_pga must be set to either 0 or 1.")
+		return
+	return chips[state["selected_board"]].set_auto_set_pga(status)
+	update_state()
+@eel.expose
+def set_input_gain(input_gain):
+	if input_gain not in [1, 2, 4, 8, 16, 32, 64, 128]: 
+		error("input_gain must be one of [1, 2, 4, 8, 16, 32, 64, 128]")
+		return
+	return chips[state["selected_board"]].set_input_gain(input_gain)
+	update_state()
+@eel.expose
+def set_offset(offset):
+	if offset>4095 or offset<0: 
+		error("offset must be in the range 0-4095. 2000 corresponds to no offset.")
+		return
+	return chips[state["selected_board"]].set_offset(offset)
+	update_state()
+@eel.expose
+def set_coarse_fine_ratio(coarse_fine_ratio):
+	if coarse_fine_ratio<10 or coarse_fine_ratio>30: 
+		error("coarse_fine_ratio should be approximately 20.")
+		return
+	if coarse_fine_ratio<15 or coarse_fine_ratio>25: 
+		warning("coarse_fine_ratio should be approximately 20.")
+	return chips[state["selected_board"]].set_coarse_fine_ratio(coarse_fine_ratio)
+	update_state()
+
+# Program state
+state = {
+	"n_boards": 2,
+	"selected_board":  0,
+	"box_address": 0x50,
+	"mode": 0,
+	"out_of_lock": 0,
+	"pi_freq": 1,
+	"board_freq": 0,
+	"remote_trigg": 0,
+	"enab_gnd": 1,
+	"Vlearn": 3200,
+	"start": 25,
+	"stop": 100,
+	"start_gnd": 125,
+	"stop_gnd": 200,
+	"wf_len": 200,
+	"N": 1,
+	"step_max": 200,
+	"Gain": 10,
+	"auto_set_pga": 1,
+	"input_gain": 1,
+	"offset": 2000,
+	"coarse_fine_ratio": 20
+}
+
+def update_state():
+	state["n_boards"] = len(chips)
+	state["box_address"] = adresses[state["selected_board"]]
+	chip = chips[state["selected_board"]]
+	state["mode"] = chip.get_mode()
+	state["out_of_lock"] = chip.get_out_of_lock()
+	state["remote_trigg"] = chip.get_remote_trigg()
+	state["enab_gnd"] = chip.get_enab_gnd()
+	state["Vlearn"] = chip.get_Vlearn()
+	state["start"] = chip.get_start()
+	state["stop"] = chip.get_stop()
+	state["start_gnd"] = chip.get_start_gnd()
+	state["stop_gnd"] = chip.get_stop_gnd()
+	state["wf_len"] = chip.get_wf_len()
+	state["N"] = chip.get_N()
+	state["step_max"] = chip.get_step_max()
+	state["Gain"] = chip.get_Gain()
+	state["auto_set_pga"] = chip.get_auto_set_pga()
+	state["input_gain"] = chip.get_input_gain()
+	state["offset"] = chip.get_offset()
+	state["coarse_fine_ratio"] = chip.get_coarse_fine_ratio()
+
+	eel.renderUI(state)
+
+
+###################################
+## START THE GUI
+###################################
+
+my_options = {
+	'mode': "chrome-app", #chrome-app
+	'host': 'localhost',
+	'port': 8107,
+	'size':(710, 725),
+	#'chromeFlags': ["--start-fullscreen", "--browser-startup-dialog"]
+}
+
+
+eel.init('web')
+eel.start('main.html', options=my_options, block=False)
+
+# Detect all boards
+import os
+import subprocess
+import re
+
+chips = []
+adresses = []
+# TO DO
+'''
+p = subprocess.Popen(['i2cdetect', '-y','1'],stdout=subprocess.PIPE,)
+for i in range(0,9):
+	line = str(p.stdout.readline())[2:]
+	for match in re.finditer("[0-9a-f]+", line):
+		adresses.append(int(match, 16))
+		chips.append(ADUCv2p1(int(match, 16),True))
+update_state()
+'''
+	
+	
+
+
+eel.renderUI(state)
+i = 0
+while(True):
+	eel.renderUI(state) # TO DO
+	# save_waveform() # TO DO
+	eel.sleep(1/state["pi_freq"])
+	if(i%100==0):
+		clean_old_files()
+	i += 1
+
+	
+	
+
+print(state)
+
+

BIN
pi/tmp.npy


+ 81 - 0
pi/web/main.css

@@ -0,0 +1,81 @@
+body{
+	margin:0px;
+}
+#app{
+	background: whitesmoke;
+	width: 700px;
+	height: 715px;
+	font-family: sans-serif;
+	font-size: 12px;
+}
+.spacing {
+    height: 14px;
+    margin-left: 10px;
+    margin-right: 10px;
+    border-right: 1px solid black;
+    display: inline-block;
+    /* position: relative; */
+}
+span{
+	margin-bottom: 10px;
+}
+.row {
+    /*display: flex;*/
+    flex-direction: row;
+    justify-content: space-evenly;
+}
+
+
+#tabs{
+	height: 30px;
+	font-size: 0px; /*Hack*/
+	background: white;
+}
+.tab {
+	font-size: 14px;
+    display: inline-block;
+    padding-top: 10px;
+    padding-bottom: 5px;
+    border-right: 1px solid grey;
+    padding-right: 14px;
+    padding-left: 14px;
+    background: white;
+    box-shadow: inset 0px -2px 2px 0px rgb(243, 225, 225);
+}
+.tab.active{
+	background: whitesmoke;
+	box-shadow: none;
+}
+
+#boxInformation {
+    padding-top: 20px;
+    padding-left: 20px;
+    padding-right: 20px;
+}
+
+#graphs{
+	height: 400px;
+}
+
+#longGraph, #waveformGraph{
+	width:100%;
+	height: 250px;
+	margin: 10px;
+	border: 1px solid black;
+}
+
+input[type="text"]{
+	width: 50px;
+	margin-left: 10px;
+}
+input[type="text"]:disabled{
+	background: rgba(0,0,0,0);
+}
+input[type="radio"], input[type="checkbox"]{
+	margin-left: 10px;
+}
+.label {
+    display: inline-block;
+    color: rgb(115, 115, 115);
+    font-style: italic;
+}

+ 132 - 0
pi/web/main.html

@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<script type="text/javascript" src="/eel.js"></script>
+	<script src="plotly-latest.min.js"></script>
+	<script type="text/javascript" src="toastify.js"></script>
+	<link rel="stylesheet" type="text/css" href="toastify.css">
+	<script type="text/javascript" src="main.js"></script>
+	<link rel="stylesheet" type="text/css" href="main.css">
+	<title> Stabilization Board software </title>
+</head>
+<body onload="onload()">
+	<div id="app">
+		<div id="tabs">
+			<div class="tab active" i="0">Board 0</div>
+			<div class="tab" i="1">Board 1</div>
+			<div class="tab" i="2">Board 2</div>
+			<div class="tab" i="3">Board 3</div>
+			<div class="tab" i="4">Board 4</div>
+			<div class="tab" i="5">Board 5</div>
+			<div class="tab" i="6">Board 6</div>
+			<div class="tab" i="7">Board 7</div>
+		</div>
+		<div id="boxInformation">
+			<div class="row">
+				<span>Box address</span><input type="text" id="boxAddress" disabled>
+				<span class="spacing">&nbsp</span>
+				<input type="radio" id="isLearn" checked disabled> Learn
+				<input type="radio" id="isLock" disabled> Lock
+				<span class="spacing">&nbsp</span>
+				<input type="checkbox" id="outOfLock" disabled checked> Out of lock
+			</div>
+			
+			<div class="row">
+				<span>Pi freq. / Hz</span><input type="text" id="piFreq">
+				<span class="spacing">&nbsp</span>
+				<span>Board freq. / Hz</span><input type="text" id="boardFreq" disabled>
+				<span class="spacing">&nbsp</span>
+				<input type="checkbox" id="remoteTrigg"> Ignore trigger
+			</div>
+		</div>
+		<div class="row" style="display: flex; flex-direction: horizontal">
+			<div id="graphs" style="width: 60%">
+				<div style="padding:4px; width:93%;">
+					<div class="row" style="margin-left: 10px">
+						<select id="waveformGraphSelect">
+						</select>
+						<span class="spacing">&nbsp</span>
+						<input type="checkbox" id="waveformGraphAutoupdate" checked> Autoupdate
+					</div>
+					<div class="row" style="margin-left: 10px; font-style:italic">
+						<span id="waveformGraphText"></span>
+					</div>
+					<div id="waveformGraph">
+					</div>
+					<div class="row" style="margin-left: 10px">
+						X: <select id="longGraphX">
+							<option value="0">Wf. number</option>
+							<option value="1">Time / min</option>
+						</select>
+						Y: <select id="longGraphY">
+							<option value="2">Signal</option>
+							<option value="3">Gnd</option>
+							<option value="4">Signal - Gnd</option>
+							<option value="5">Signal Std</option>
+							<option value="6">Gnd Std</option>
+							<option value="7">Mode</option>
+							<option value="8">Out of lock</option>
+							<option value="9">Broad output</option>
+							<option value="10">Fine output</option>
+						</select>
+						<span class="spacing">&nbsp</span>
+						<input type="checkbox" id="longGraphAutoupdate" checked> Autoupdate
+					</div>
+					<div id="longGraph">
+					</div>
+				</div>
+			</div>
+			<div style="width: 40%; padding: 10px">
+				<span class="label">____ Learning options ________________</span>
+				<div class="row">
+					<input type="checkbox" id="enabGnd"> Subtract ground
+					<span class="spacing">&nbsp</span>
+					<span>Vlearn</span><input type="text" id="Vlearn">
+				</div>
+				<div class="row">
+					<span>Start</span><input type="text" id="start">
+					<span class="spacing">&nbsp</span>
+					<span>Stop</span><input type="text" id="stop">
+				</div>
+				<div class="row" id="gndOptions">
+					<span>Start gnd</span><input type="text" id="startGnd">
+					<span class="spacing">&nbsp</span>
+					<span>Stop gnd</span><input type="text" id="stopGnd">
+				</div>
+				<div class="row" id="gndOptions">
+					<span>Nº of wf</span><input type="text" id="N">
+					<span class="spacing">&nbsp</span>
+					<span>Wf length</span><input type="text" id="wfLen">
+				</div>
+				<span class="label">____ Locking options _________________</span>
+				<div class="row">
+					<span>Max. step</span><input type="text" id="stepMax">
+					<span class="spacing" style="opacity: 0">&nbsp</span>
+				</div>
+				<div class="row">
+					<span>Loop gain</span><input type="text" id="Gain">
+					<span class="spacing">&nbsp</span>
+					<input type="button" id="calibrateGain" value="Calibrate gain">
+				</div>
+				<span class="label">____ Input options _________________</span>
+				<div class="row">
+					<input type="checkbox" id="autoSetPga"> Auto configure input
+					<span class="spacing" style="opacity: 0">&nbsp</span>
+				</div>
+				<div class="row">
+					<span>Input gain</span><input type="text" id="inputGain">
+					<span class="spacing">&nbsp</span>
+					<span> Offset</span><input type="text" id="offset">
+				</div>
+				<span class="label">____ Output options _________________</span>
+				<div class="row">
+					<span>Broad/fine ratio</span><input type="text" id="coarseFineRatio">
+					<span class="spacing">&nbsp</span>
+					<input type="button" id="calibrateCoarseFineRatio" value="Calibrate ratio">
+				</div>
+
+			</div>
+		</div>
+	</div>
+</body>
+</html>

+ 332 - 0
pi/web/main.js

@@ -0,0 +1,332 @@
+eel.expose(renderUI);
+eel.expose(error)
+eel.expose(warning)
+
+// Helper functions
+
+function range(n){
+	return [...Array(n).keys()];
+}
+
+function onload(){ //Bind events
+	// Changing tabs
+	tabs = document.querySelector('#tabs').children
+	for (var i = 0; i < tabs.length; i++){
+		tabs[i].addEventListener("click", function(event){
+			eel.set_selected_board(event.srcElement.getAttribute("i"))
+		})
+	}
+	// Box information
+	document.querySelector('#piFreq').addEventListener("focusout", function(event){
+		eel.set_pi_freq(parseFloat(event.srcElement.value))
+	})
+	document.querySelector('#remoteTrigg').addEventListener("click", function(event){
+		eel.set_remote_trigg(event.srcElement.checked ? 1 : 0)
+	})
+	// Learning options
+	document.querySelector('#enabGnd').addEventListener("click", function(event){
+		eel.set_enab_gnd(event.srcElement.checked ? 1 : 0)
+	})
+	document.querySelector('#Vlearn').addEventListener("focusout", function(event){
+		eel.set_Vlearn(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#start').addEventListener("focusout", function(event){
+		eel.set_start(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#stop').addEventListener("focusout", function(event){
+		eel.set_stop(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#startGnd').addEventListener("focusout", function(event){
+		eel.set_start_gnd(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#stopGnd').addEventListener("focusout", function(event){
+		eel.set_stop_gnd(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#N').addEventListener("focusout", function(event){
+		eel.set_N(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#wfLen').addEventListener("focusout", function(event){
+		eel.set_wf_len(parseInt(event.srcElement.value))
+	})
+	// Locking options
+	document.querySelector('#stepMax').addEventListener("focusout", function(event){
+		eel.set_max_step(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#Gain').addEventListener("focusout", function(event){
+		eel.set_Gain(parseFloat(event.srcElement.value))
+	})
+	document.querySelector('#calibrateGain').addEventListener("click", function(event){
+		eel.calibrate_gain()
+	})
+	// Input options
+	document.querySelector('#autoSetPga').addEventListener("click", function(event){
+		eel.set_auto_set_pga(event.srcElement.checked ? 1 : 0)
+	})
+	document.querySelector('#inputGain').addEventListener("focusout", function(event){
+		eel.set_input_gain(parseInt(event.srcElement.value))
+	})
+	document.querySelector('#offset').addEventListener("focusout", function(event){
+		eel.set_offset(parseInt(event.srcElement.value))
+	})
+	// Output options
+	document.querySelector('#coarseFineRatio').addEventListener("focusout", function(event){
+		eel.set_coarse_fine_ratio(parseFloat(event.srcElement.value))
+	})
+	document.querySelector('#calibrateCoarseFineRatio').addEventListener("click", function(event){
+		eel.calibrate_coarse_fine_ratio()
+	})
+	// Graphs
+	document.getElementById("waveformGraphSelect").addEventListener("change", function(){
+		document.querySelector('#waveformGraphAutoupdate').checked = false
+		loadGraph()
+	})
+	document.getElementById("longGraphX").addEventListener("change", function(){
+		loadLongGraph()
+	})
+	document.getElementById("longGraphY").addEventListener("change", function(){
+		loadLongGraph()
+	})
+
+	setTimeout(loop, 100)
+
+}
+
+j = 0
+function loop(){
+	if(document.getElementById("waveformGraphSelect") != document.activeElement){
+		loadGraphList()
+	}
+	if(document.querySelector('#longGraphAutoupdate').checked){
+		// Don't update this too often
+		if(j%10==0){loadLongGraph()}
+	}
+	j++
+	setTimeout(loop, 1000)
+}
+
+function renderUI(state){
+	//console.log('Updating UI')
+
+	// BOX INFORMATION
+	tabs = document.querySelector('#tabs').children
+	for (var i = 0; i < tabs.length; i++){
+		tabs[i].classList.remove('active')
+		if(i>=state.n_boards){
+			tabs[i].style.opacity = 0
+		}
+		else{
+			tabs[i].style.opacity = 1
+		}
+	}
+	tabs[state.selected_board].classList.add('active')
+
+	document.querySelector('#boxAddress').value = "0x"+state.box_address.toString(16)
+
+	document.querySelector('#isLearn').checked = false
+	document.querySelector('#isLock').checked = false
+	if(state.mode == 0) document.querySelector('#isLearn').checked = true
+	if(state.mode == 1) document.querySelector('#isLock').checked = true
+
+	document.querySelector('#outOfLock').checked = false
+	if(state.out_of_lock == 1) document.querySelector('#outOfLock').checked = true
+
+	document.querySelector('#piFreq').value = state.pi_freq
+
+	document.querySelector('#boardFreq').value = state.board_freq
+
+	document.querySelector('#remoteTrigg').checked = false
+	if(state.remote_trigg == 1) document.querySelector('#remoteTrigg').checked = true
+
+	// LEARNING OPTIONS
+	document.querySelector('#enabGnd').checked = state.enab_gnd
+
+	document.querySelector('#Vlearn').value = state.Vlearn
+
+	document.querySelector('#start').value = state.start
+
+	document.querySelector('#stop').value = state.stop
+
+	document.querySelector('#startGnd').value = state.start_gnd
+
+	document.querySelector('#stopGnd').value = state.stop_gnd
+
+	document.querySelector('#N').value = state.N
+
+	document.querySelector('#wfLen').value = state.wf_len
+
+	// LOCKING OPTIONS
+	document.querySelector('#stepMax').value = state.step_max
+
+	document.querySelector('#Gain').value = state.Gain
+
+	// INPUT OPTIONS
+	document.querySelector('#autoSetPga').checked = state.auto_set_pga
+	document.querySelector('#inputGain').disabled = state.auto_set_pga==1
+	document.querySelector('#offset').disabled = state.auto_set_pga==1
+
+	document.querySelector('#inputGain').value = state.input_gain
+
+	document.querySelector('#offset').value = state.offset
+
+	// OUTPUT OPTIONS
+	document.querySelector('#coarseFineRatio').value = state.coarse_fine_ratio
+
+}
+
+
+async function loadGraphList(){
+	files = await eel.listFiles('data/waveforms/')()
+	timestamps = files.map(s => parseInt(s.replace('.csv', '')))
+	timestamps.sort()
+	dates = []
+	for(timestamp of timestamps){
+		var d = new Date(0); 
+		d.setUTCMilliseconds(timestamp)*1000;
+		dates.push(d.toLocaleString() + "." + d.getMilliseconds())
+	}
+
+	var list = document.getElementById("waveformGraphSelect")
+	index = list.selectedIndex
+	list.innerHTML = ""
+	for (var i = 0; i < dates.length; i++){
+		var element = document.createElement("option")
+		element.setAttribute('timestamp', timestamps[i])
+		element.innerText = dates[i]
+		list.append(element);
+	}
+	list.selectedIndex = index
+	if(document.querySelector('#waveformGraphAutoupdate').checked){
+		list.selectedIndex = list.children.length-1
+		if(list.children.length-1 != index) loadGraph()
+	}
+	else if(index>-1){
+		list.selectedIndex = index
+	}
+	else{
+		loadGraph()
+	}
+}
+
+async function loadGraph(){
+	option = document.querySelector('#waveformGraphSelect')[document.querySelector('#waveformGraphSelect').selectedIndex]
+	timestamp = option.getAttribute('timestamp')
+	csv = await eel.loadFile('data/waveforms/'+timestamp+'.csv')()
+	document.querySelector('#waveformGraphText').innerText = "Signal: "+csv[8]+" - Gnd: "+csv[9]+" - Signal_std: "+csv[10].toFixed(2)+" - Gnd_std: "+csv[11].toFixed(2)
+
+	var data = [{
+	  x: range(csv[12]),
+	  y: csv.slice(13),
+	  type: 'scatter'
+	},{
+	  x: [csv[2], csv[2]],
+	  y: [0, Math.max(...csv.slice(13))],
+	  line: {
+    	color: 'red'
+      },
+	  type: 'scatter',
+	  mode: 'lines'
+	},{
+	  x: [csv[3], csv[3]],
+	  y: [0, Math.max(...csv.slice(13))],
+	  line: {
+    	color: 'red'
+      },
+	  type: 'scatter',
+	  mode: 'lines'
+	},{
+	  x: [csv[4], csv[4]],
+	  y: [0, Math.max(...csv.slice(13))],
+	  line: {
+    	color: 'green'
+      },
+	  type: 'scatter',
+	  mode: 'lines'
+	},{
+	  x: [csv[5], csv[5]],
+	  y: [0, Math.max(...csv.slice(13))],
+	  line: {
+    	color: 'green'
+      },
+	  type: 'scatter',
+	  mode: 'lines'
+	}];
+	var layout = {
+	  margin: {
+		l: 50,
+		r: 10,
+		b: 50,
+		t: 10,
+		pad: 4
+	  },
+	  xaxis: {
+		title: 'Time',
+		showgrid: true,
+	  },
+	  yaxis: {
+		title: 'Input voltage',
+		showgrid: true
+	  },
+	  showlegend: false
+	};
+	Plotly.newPlot('waveformGraph', data, layout);
+}
+
+async function loadLongGraph(){
+	csv = await eel.loadLongTerm()()
+	xIndex = parseInt(document.querySelector('#longGraphX').children[document.querySelector('#longGraphX').selectedIndex].value)
+	xTitle = document.querySelector('#longGraphX').children[document.querySelector('#longGraphX').selectedIndex].innerText
+	yIndex = parseInt(document.querySelector('#longGraphY').children[document.querySelector('#longGraphY').selectedIndex].value)
+	yTitle = document.querySelector('#longGraphY').children[document.querySelector('#longGraphY').selectedIndex].innerText
+
+
+	var data = [{
+	  x: csv.map(l => l[xIndex]),
+	  y: csv.map(l => l[yIndex]),
+	  type: 'scatter'
+	}]
+	if(xIndex==1){
+		max = Math.max(...data[0].x)
+		data[0].x = data[0].x.map(v => (v-max)/60)
+	}
+
+	var layout = {
+	  margin: {
+		l: 50,
+		r: 10,
+		b: 50,
+		t: 10,
+		pad: 4
+	  },
+	  xaxis: {
+		title: xTitle,
+		showgrid: true,
+	  },
+	  yaxis: {
+		title: yTitle,
+		showgrid: true
+	  },
+	  showlegend: false
+	};
+	Plotly.newPlot('longGraph', data, layout);
+	
+}
+
+function error(txt){
+	Toastify({
+	  text: "Error: "+txt,
+	  gravity: 'bottom',
+	  position: 'left',
+	  close: true,
+	  backgroundColor: "#ef4041",
+	  duration: 3000,}).showToast()
+}
+
+function warning(txt){
+	Toastify({
+	  text: "Warning: "+txt,
+	  gravity: 'bottom',
+	  position: 'left',
+	  close: true,
+	  backgroundColor: "#e36d25",
+	  duration: 3000,}).showToast()
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 7 - 0
pi/web/plotly-latest.min.js


+ 78 - 0
pi/web/toastify.css

@@ -0,0 +1,78 @@
+/*!
+ * Toastify js 1.6.1
+ * https://github.com/apvarun/toastify-js
+ * @license MIT licensed
+ *
+ * Copyright (C) 2018 Varun A P
+ */
+
+.toastify {
+    padding: 12px 20px;
+    color: #ffffff;
+    display: inline-block;
+    box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
+    background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
+    background: linear-gradient(135deg, #73a5ff, #5477f5);
+    position: fixed;
+    opacity: 0;
+    transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
+    border-radius: 2px;
+    cursor: pointer;
+    text-decoration: none;
+    max-width: calc(50% - 20px);
+    z-index: 2147483647;
+}
+
+.toastify.on {
+    opacity: 1;
+}
+
+.toast-close {
+    opacity: 0.4;
+    padding: 0 5px;
+}
+
+.toastify-right {
+    right: 15px;
+}
+
+.toastify-left {
+    left: 15px;
+}
+
+.toastify-top {
+    top: -150px;
+}
+
+.toastify-bottom {
+    bottom: -150px;
+}
+
+.toastify-rounded {
+    border-radius: 25px;
+}
+
+.toastify-avatar {
+    width: 1.5em;
+    height: 1.5em;
+    margin: 0 5px;
+    border-radius: 2px;
+}
+
+.toastify-center {
+    margin-left: auto;
+    margin-right: auto;
+    left: 0;
+    right: 0;
+    max-width: fit-content;
+}
+
+@media only screen and (max-width: 360px) {
+    .toastify-right, .toastify-left {
+        margin-left: auto;
+        margin-right: auto;
+        left: 0;
+        right: 0;
+        max-width: fit-content;
+    }
+}

+ 349 - 0
pi/web/toastify.js

@@ -0,0 +1,349 @@
+/*!
+ * Toastify js 1.6.1
+ * https://github.com/apvarun/toastify-js
+ * @license MIT licensed
+ *
+ * Copyright (C) 2018 Varun A P
+ */
+(function(root, factory) {
+  if (typeof module === "object" && module.exports) {
+    module.exports = factory();
+  } else {
+    root.Toastify = factory();
+  }
+})(this, function(global) {
+  // Object initialization
+  var Toastify = function(options) {
+      // Returning a new init object
+      return new Toastify.lib.init(options);
+    },
+    // Library version
+    version = "1.6.1";
+
+  // Defining the prototype of the object
+  Toastify.lib = Toastify.prototype = {
+    toastify: version,
+
+    constructor: Toastify,
+
+    // Initializing the object with required parameters
+    init: function(options) {
+      // Verifying and validating the input object
+      if (!options) {
+        options = {};
+      }
+
+      // Creating the options object
+      this.options = {};
+
+      this.toastElement = null;
+
+      // Validating the options
+      this.options.text = options.text || "Hi there!"; // Display message
+      this.options.duration = options.duration || 3000; // Display duration
+      this.options.selector = options.selector; // Parent selector
+      this.options.callback = options.callback || function() {}; // Callback after display
+      this.options.destination = options.destination; // On-click destination
+      this.options.newWindow = options.newWindow || false; // Open destination in new window
+      this.options.close = options.close || false; // Show toast close icon
+      this.options.gravity = options.gravity == "bottom" ? "toastify-bottom" : "toastify-top"; // toast position - top or bottom
+      this.options.positionLeft = options.positionLeft || false; // toast position - left or right
+      this.options.position = options.position || ''; // toast position - left or right
+      this.options.backgroundColor = options.backgroundColor; // toast background color
+      this.options.avatar = options.avatar || ""; // img element src - url or a path
+      this.options.className = options.className || ""; // additional class names for the toast
+      this.options.stopOnFocus = options.stopOnFocus === undefined? true: options.stopOnFocus; // stop timeout on focus
+      this.options.onClick = options.onClick; // Callback after click
+
+      // Returning the current object for chaining functions
+      return this;
+    },
+
+    // Building the DOM element
+    buildToast: function() {
+      // Validating if the options are defined
+      if (!this.options) {
+        throw "Toastify is not initialized";
+      }
+
+      // Creating the DOM object
+      var divElement = document.createElement("div");
+      divElement.className = "toastify on " + this.options.className;
+
+      // Positioning toast to left or right or center
+      if (!!this.options.position) {
+        divElement.className += " toastify-" + this.options.position;
+      } else {
+        // To be depreciated in further versions
+        if (this.options.positionLeft === true) {
+          divElement.className += " toastify-left";
+          console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
+        } else {
+          // Default position
+          divElement.className += " toastify-right";
+        }
+      }
+
+      // Assigning gravity of element
+      divElement.className += " " + this.options.gravity;
+
+      if (this.options.backgroundColor) {
+        divElement.style.background = this.options.backgroundColor;
+      }
+
+      // Adding the toast message
+      divElement.innerHTML = this.options.text;
+
+      if (this.options.avatar !== "") {
+        var avatarElement = document.createElement("img");
+        avatarElement.src = this.options.avatar;
+
+        avatarElement.className = "toastify-avatar";
+
+        if (this.options.position == "left" || this.options.positionLeft === true) {
+          // Adding close icon on the left of content
+          divElement.appendChild(avatarElement);
+        } else {
+          // Adding close icon on the right of content
+          divElement.insertAdjacentElement("beforeend", avatarElement);
+        }
+      }
+
+      // Adding a close icon to the toast
+      if (this.options.close === true) {
+        // Create a span for close element
+        var closeElement = document.createElement("span");
+        closeElement.innerHTML = "&#10006;";
+
+        closeElement.className = "toast-close";
+
+        // Triggering the removal of toast from DOM on close click
+        closeElement.addEventListener(
+          "click",
+          function(event) {
+            event.stopPropagation();
+            this.removeElement(event.target.parentElement);
+            window.clearTimeout(event.target.parentElement.timeOutValue);
+          }.bind(this)
+        );
+
+        // Clear timeout while toast is focused
+        if (this.options.stopOnFocus && this.options.duration > 0) {
+          const self = this;
+          // stop countdown
+          divElement.addEventListener(
+            "mouseover",
+            function(event) {
+              window.clearTimeout(divElement.timeOutValue);
+            }
+          )
+          // add back the timeout
+          divElement.addEventListener(
+            "mouseleave",
+            function() {
+              divElement.timeOutValue = window.setTimeout(
+                function() {
+                  // Remove the toast from DOM
+                  self.removeElement(divElement);
+                },
+                self.options.duration
+              )
+            }
+          )
+        }
+
+        //Calculating screen width
+        var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
+
+        // Adding the close icon to the toast element
+        // Display on the right if screen width is less than or equal to 360px
+        if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
+          // Adding close icon on the left of content
+          divElement.insertAdjacentElement("afterbegin", closeElement);
+        } else {
+          // Adding close icon on the right of content
+          divElement.appendChild(closeElement);
+        }
+      }
+
+      // Adding an on-click destination path
+      if (typeof this.options.destination !== "undefined") {
+        divElement.addEventListener(
+          "click",
+          function(event) {
+            event.stopPropagation();
+            if (this.options.newWindow === true) {
+              window.open(this.options.destination, "_blank");
+            } else {
+              window.location = this.options.destination;
+            }
+          }.bind(this)
+        );
+      }
+
+      if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
+        divElement.addEventListener(
+          "click",
+          function(event) {
+            event.stopPropagation();
+            this.options.onClick();            
+          }.bind(this)
+        );
+      }
+
+      // Returning the generated element
+      return divElement;
+    },
+
+    // Displaying the toast
+    showToast: function() {
+      // Creating the DOM object for the toast
+      this.toastElement = this.buildToast();
+
+      // Getting the root element to with the toast needs to be added
+      var rootElement;
+      if (typeof this.options.selector === "undefined") {
+        rootElement = document.body;
+      } else {
+        rootElement = document.getElementById(this.options.selector);
+      }
+
+      // Validating if root element is present in DOM
+      if (!rootElement) {
+        throw "Root element is not defined";
+      }
+
+      // Adding the DOM element
+      rootElement.insertBefore(this.toastElement, rootElement.firstChild);
+
+      // Repositioning the toasts in case multiple toasts are present
+      Toastify.reposition();
+
+      if (this.options.duration > 0) {
+        this.toastElement.timeOutValue = window.setTimeout(
+          function() {
+            // Remove the toast from DOM
+            this.removeElement(this.toastElement);
+          }.bind(this),
+          this.options.duration
+        ); // Binding `this` for function invocation
+      }
+
+      // Supporting function chaining
+      return this;
+    },
+
+    hideToast: function() {
+      if (this.toastElement.timeOutValue) {
+        clearTimeout(this.toastElement.timeOutValue);
+      }
+      this.removeElement(this.toastElement);
+    },
+
+    // Removing the element from the DOM
+    removeElement: function(toastElement) {
+      // Hiding the element
+      // toastElement.classList.remove("on");
+      toastElement.className = toastElement.className.replace(" on", "");
+
+      // Removing the element from DOM after transition end
+      window.setTimeout(
+        function() {
+          // Remove the elemenf from the DOM
+          toastElement.parentNode.removeChild(toastElement);
+
+          // Calling the callback function
+          this.options.callback.call(toastElement);
+
+          // Repositioning the toasts again
+          Toastify.reposition();
+        }.bind(this),
+        400
+      ); // Binding `this` for function invocation
+    },
+  };
+
+  // Positioning the toasts on the DOM
+  Toastify.reposition = function() {
+    // Top margins with gravity
+    var topLeftOffsetSize = {
+      top: 15,
+      bottom: 15,
+    };
+    var topRightOffsetSize = {
+      top: 15,
+      bottom: 15,
+    };
+    var offsetSize = {
+      top: 15,
+      bottom: 15,
+    };
+
+    // Get all toast messages on the DOM
+    var allToasts = document.getElementsByClassName("toastify");
+
+    var classUsed;
+
+    // Modifying the position of each toast element
+    for (var i = 0; i < allToasts.length; i++) {
+      // Getting the applied gravity
+      if (containsClass(allToasts[i], "toastify-top") === true) {
+        classUsed = "toastify-top";
+      } else {
+        classUsed = "toastify-bottom";
+      }
+
+      var height = allToasts[i].offsetHeight;
+      classUsed = classUsed.substr(9, classUsed.length-1)
+      // Spacing between toasts
+      var offset = 15;
+
+      var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
+
+      // Show toast in center if screen with less than or qual to 360px
+      if (width <= 360) {
+        // Setting the position
+        allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
+
+        offsetSize[classUsed] += height + offset;
+      } else {
+        if (containsClass(allToasts[i], "toastify-left") === true) {
+          // Setting the position
+          allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
+
+          topLeftOffsetSize[classUsed] += height + offset;
+        } else {
+          // Setting the position
+          allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
+
+          topRightOffsetSize[classUsed] += height + offset;
+        }
+      }
+    }
+
+    // Supporting function chaining
+    return this;
+  };
+
+  function containsClass(elem, yourClass) {
+    if (!elem || typeof yourClass !== "string") {
+      return false;
+    } else if (
+      elem.className &&
+      elem.className
+        .trim()
+        .split(/\s+/gi)
+        .indexOf(yourClass) > -1
+    ) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  // Setting up the prototype for the init object
+  Toastify.lib.init.prototype = Toastify.lib;
+
+  // Returning the Toastify function to be assigned to the window object/module
+  return Toastify;
+});