DLOG4CHC.asm 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. ;==============================================================================
  2. ; File name : DLOG4CHC.ASM
  3. ;
  4. ; Originator : Advanced Embeeded Control (AEC)
  5. ; Texas Instruments Inc.
  6. ;
  7. ; Description : 4-Channel Data logging module
  8. ;
  9. ; Date : 02/01/2002 (DD/MM/YYYY)
  10. ;==============================================================================
  11. ; Routine Name: data_log_update
  12. ;
  13. ; C prototype : void DLOG_4CH_update(DLOG_4CH_handle);
  14. ; void DLOG_4CH_init(DLOG_4CH_handle);
  15. ;
  16. ; The struct object is defined in the header file "dlog_4ch.h" as follows:
  17. ;
  18. ; typedef struct {
  19. ; long task; /* Variable: Task address pointer */
  20. ; int *iptr1; /* Input: First input pointer (Q15) */
  21. ; int *iptr2; /* Input: Second input pointer (Q15) */
  22. ; int *iptr3; /* Input: Third input pointer (Q15) */
  23. ; int *iptr4; /* Input: Fourth input pointer (Q15) */
  24. ; int trig_value; /* Input: Trigger point (Q15) */
  25. ; int prescalar; /* Parameter: Data log prescale */
  26. ; int skip_cntr; /* Variable: Data log skip counter */
  27. ; int cntr; /* Variable: Data log counter */
  28. ; long write_ptr; /* Variable: Graph address pointer */
  29. ; int size; /* Parameter: Maximum data DLOG_4CH_buffer */
  30. ; int (*init)(); /* Pointer to init function */
  31. ; int (*update)(); /* Pointer to update function */
  32. ; } DLOG_4CH;
  33. ;==============================================================================
  34. ; External Reference
  35. .def _DLOG_4CH_update
  36. .def _DLOG_4CH_init
  37. ; Data log buffer definition
  38. BUFF_SIZE .set 0190h
  39. DLOG_4CH_buff1 .usect "DLOG", BUFF_SIZE
  40. DLOG_4CH_buff2 .usect "DLOG", BUFF_SIZE
  41. DLOG_4CH_buff3 .usect "DLOG", BUFF_SIZE
  42. DLOG_4CH_buff4 .usect "DLOG", BUFF_SIZE
  43. ;==============================================================================
  44. ; Initialization Function
  45. ;==============================================================================
  46. _DLOG_4CH_init:
  47. MOVL XAR5,#POS_TRIG_S1
  48. MOVL *XAR4,XAR5 ; task=#POS_TRIG_S1
  49. ADDB XAR4,#10 ; XAR4->trig_value
  50. MOV *+XAR4[2],#0
  51. MOVL XAR5,#DLOG_4CH_buff1
  52. MOVL *+XAR4[4],XAR5 ; write_ptr=DLOG_4CH_buff1
  53. MOV AL,*+XAR4[6] ; ACC=size
  54. MOV *+XAR4[3],AL ; cntr=size
  55. LRETR
  56. ;==============================================================================
  57. ; Datalog Update Function
  58. ;==============================================================================
  59. _DLOG_4CH_update:
  60. SETC SXM
  61. MOVL XAR5,XAR4 ; XAR4->task
  62. MOVL XAR7,*XAR4++ ; XAR4->iptr1, XAR7=task
  63. ADDB XAR5,#10 ; XAR5->trig_value
  64. LB *XAR7 ; Branch to TASK
  65. POS_TRIG_S1:
  66. MOV ACC,*XAR5 ; ACC=trig_value
  67. MOVL XAR6,*XAR4 ; XAR6=iptr1
  68. SUB ACC,*XAR6 ; ACC=(trig_value - *iptr1)
  69. BF DL_EXIT,LEQ ; Exit if ACC <= 0
  70. MOVL XAR6,#POS_TRIG_S2
  71. MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
  72. LRETR
  73. POS_TRIG_S2:
  74. MOV ACC,*XAR5 ; ACC=trig_value
  75. MOVL XAR6,*XAR4 ; XAR6=iptr1
  76. SUB ACC,*XAR6 ; ACC=(trig_value - *iptr1)
  77. BF DL_EXIT,GEQ ; Exit if ACC >= 0
  78. MOVL XAR6,#DL_TRIGGERED
  79. MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
  80. LRETR
  81. DL_TRIGGERED:
  82. INC *+XAR5[2] ; skip_cntr=skip_cntr+1
  83. MOV ACC,*+XAR5[2] ; ACC=skip_cntr
  84. SUB ACC,*+XAR5[1] ; ACC=skip_cntr-prescalar
  85. SBF DL_EXIT,NEQ ; if (skip_cntr+1) < prescalar, then exit
  86. MOV *+XAR5[2],#0 ; skip_cntr=0
  87. MOV ACC,*+XAR5[3] ; ACC=cntr
  88. SBF DLOG_END,EQ
  89. DEC *+XAR5[3] ; cntr=cntr-1
  90. ADDB XAR5,#4 ; XAR5->write_ptr
  91. MOVL XAR6,*XAR5 ; XAR6=write_ptr
  92. ADDB XAR6,#1 ; XAR6=write_ptr+1
  93. MOVL *XAR5,XAR6 ; write_ptr=write_ptr + 1
  94. SUBB XAR6,#1 ; XAR6=write_ptr
  95. MOV AR0,#BUFF_SIZE ; AR0=BUFF_SIZE
  96. ; Log sample pointed by IPTR1
  97. MOVL XAR7,*XAR4++ ; XAR7=iptr1
  98. MOV AL,*XAR7 ; AL=*iptr1
  99. NOP *,ARP6
  100. MOV *0++,AL ; *write_ptr=*iptr1, XAR6=write_ptr+size
  101. ; Log sample pointed by IPTR2
  102. MOVL XAR7,*XAR4++ ; XAR7=iptr2
  103. MOV AL,*XAR7 ; AL=*iptr2
  104. NOP *,ARP6
  105. MOV *0++,AL ; *write_ptr=*iptr2, XAR6=write_ptr+size
  106. ; Log sample pointed by IPTR3
  107. MOVL XAR7,*XAR4++ ; XAR7=iptr3
  108. MOV AL,*XAR7 ; AL=*iptr3
  109. NOP *,ARP6
  110. MOV *0++,AL ; *write_ptr=*iptr3, XAR6=write_ptr+size
  111. ; Log sample pointed by IPTR4
  112. MOVL XAR7,*XAR4++ ; XAR7=iptr4
  113. MOV AL,*XAR7 ; AL=*iptr4
  114. NOP *,ARP6
  115. MOV *0++,AL ; *write_ptr=*iptr4, XAR6=write_ptr+size
  116. LRETR
  117. ; Reinitialise the module to log the data when the logging is triggered next
  118. DLOG_END:
  119. MOVL XAR6,#DLOG_4CH_buff1
  120. MOVL *+XAR5[4],XAR6 ; write_ptr=DLOG_4CH_buff1
  121. MOVL XAR6,#POS_TRIG_S1
  122. MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
  123. MOV AL,*+XAR5[6] ; ACC=size
  124. MOV *+XAR5[3],AL ; cntr=size
  125. DL_EXIT:
  126. LRETR