; --------------------------------------------------------------------------------
; @Title: Perform a Task Selective Function Tracing (Chorus)
; @Description: 
;   The analyzer is programmed to record the Functions and the magic,
;   so the analyzer can use it for task specific actions.
; @Author: DIE
; @Copyright: (C) 1989-2019 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: taskfunc.cmm 15227 2019-11-06 11:57:41Z bschroefel $


; delete all predefined Alpha and Beta breakpoints
  Break.Delete /Alpha  /Beta 

; start the demo application for 200 ms to set up processes
  IF (!STATE.RUN())
    Go
  WAIT 200.ms
  Break

; set Alpha Breakpoint on magic address
  Break.Set task.config(magic)++(task.config(magicsize)-0x1) /Alpha

; set Alpha and Beta breakpoints on Function Entries/Exits
  Break.SetFunc

; Important !! Delete Breakpoints in interrupt routines
; to avoid overrun problems
;  b.d y.range(int1)  /a /b
;  b.d y.range(int2)  /a /b

; Important !! Delete Breakpoints in user tasks (no main loop traced)
; or move Alpha & Beta breakpoints to beginning and end of endless
; loops (main loops treated as functions)
;  b.d y.range(user1)  /a /b
;  b.d y.range(user2)  /a /b

; program analyzer with focus on alpha and beta breakpoints: 
  Analyzer.ReProgram 
  (
    Sample.Enabled    IF (AB||BB)
    Mark.A IF AB
    Mark.B IF BB
  )

; configure analyzer to trace functions#
  IF hardware.ICE()
   Analyzer.Mode prepost OFF
  Analyzer.Mode stack
  Analyzer.SIZE 10000.
  Analyzer.Init
  Analyzer.Arm

; start program for 10 seconds
  SCREEN.ALways
  PRINT "running program for 10 seconds..."
  Go
  WAIT 10.s
  Break
  SCREEN.ON

;configure statistic command and window
  PRINT "initializing analyzer windows..."
  Analyzer.OFF
  Analyzer.STATistic.Sort symbol
  Analyzer.list l.task func cpu TIme.REF
  Analyzer.stat.taskfunc
  Analyzer.chart.taskfunc
  PRINT ""

