; --------------------------------------------------------------------------------
; @Title: Perform a task selective function tracing (pSOS+)
; @Description: 
;   The analyzer is programmed to record the Functions and the magic,
;   so the analyzer can use it for task specific actions.
; @Keywords: psos, v21x
; @Author: DIE
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: taskfunc.cmm 7052 2014-05-05 14:33:11Z kjmal $


; delete all predefined Alpha an Beta breakpoints
  Break.Delete /Alpha /Beta

; start the demo application for 200 ms to set up processes
  IF (!STATE.RUN())
    Go.direct
  WAIT 200.ms
  Break.direct

; 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
  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.direct
  WAIT 10.s
  Break.direct
  SCREEN.ON

;configure statistic command and window
  PRINT "initializing analyzer windows..."
  Analyzer.STATistic.Sort symbol
  Analyzer.list l.task func cpu TIme.REF
  Analyzer.stat.taskfunc
  Analyzer.chart.taskfunc
  PRINT ""
