I am using a BlackFin561 running different Threads on The DSP. No I have the problem that when my code is running after a while some Thread are hang up and I got an tmk_ExceptionHandler call.
Can anybody advice!
The size of the Idle thread stack is not handled automatically, unfortunately, and must be managed in the same way that other stack sizes are.
To determine whether your stack size needs to be increased, be aware that any ISRs get run in the stack of the running thread (this is covered in the VDK manual). For this reason all threads - including the idle thread if it gets to run in the application - must have a stack large enough to accommodate allof the interrupts that can be running nested. For an idle thread stack size of 255 words it is quite likely that an ISR could easily go over that value.
VDK will dispatch a kStackOverflow panic when, after a pre-emptive context switch, the last word in a thread stack has been overwritten. If you place a watchpoint in this last word (you can determine what it is from the information in the VDK Status window) you will be able to see what is overwriting it.
I have also observed this problem for my ADSP-BF518F. But, once system services are initialised i am observing this problem. Is there any additional requirements for using system services with VDK environment?
Execution of tmk_ExceptionHandler does not in itself indicate an error. Certain types of exception are a normal part of the running of a program, and tmk_ExceptionHandler will be entered quite frequently during the execution of most applications.
tmk_ExceptionHandler is not documented because it is an internal VDK function. It transparently handles certain types of exception and resumes execution of the program. The exception types that are handled are (identified by their EXCAUSE register values):0x0:the EXCPT 0 exception. Raised explicitly by program code (within VDK). This is used by VDK when resuming execution of an pre-empted thread (i.e. a thread whose execution was suspended by an interrupt) from a runtime (i.e. API-driven) context-switch. This is a necessary part of VDK's normal operation.0x2C:the "Instruction fetch CPLB miss" exception. Occurs if an address is referenced that is not currently mapped by the instruction CPLB registers.0x26:the "Data access CPLB miss" exception. Occurs if an data address is referenced that is not currently mapped by the data CPLB registers.0X23:the "Data access CPLB protection violation" exception. Occurs (for example) on a write to an address that is mapped as read-only.
For these last three exception types, tmk_ExceptionHandler calls the runtime library's CPLB miss handler to handle the exception. For the CPLB miss exceptions this will typically involve loading an address mapping from the CPLB table in memory and resuming execution of the excepting instruction. If the handler is unable to do this (due to an illegal memory access, for instance) then it will stop execution by looping at a known symbol.
Any other exception type will be passed to the user exception handler, which is generated as part of every VDK project. These exception types may indicate a problem in your program, and if you suspect that this is happening then you should set a breakpoint in UserExceptionHandler to detect these cases. Alternatively you can place an EMUEXCPT; instruction in the code for UserExceptionHandler. This will cause execution to stop at this instruction when connected to the emulator.
If you detect an unhandled exception in this way then the contents of the EXCAUSE (which is a field within the SQSTAT register) will tell you the type of the exception. This should give an indication of the nature of the problem.
first many thanks for your detailed description. I figured out what the problem was which was responsible for triggering the tmk_ExceptionHandler. Actually it was the size of the idle stack. In my VDK project the size for the IDLE Thread stack was set by default to 255. But the idle thread is managed by the VDK. When I did open the VDK Status pages I have noticed that the required size by the idle stack is above 300 words. When I did enlarge the stack size for the idle thread to 512 words I found out that the tmk_Exception was gone. I am now wondering what causes the huge required size for the IDLE Thread. Should this size not be handled by the VDK? What criterias do influence the required stack size for the idle thread?
Retrieving data ...