beautypg.com

Echelon Neuron User Manual

Page 55

background image

}

In addition, you can add a callback function to the test application, and modify

the assembly source to call the Neuron C callback function. This callback can

perform diagnostic functions, or you can use it simply to set a breakpoint in the

NodeBuilder Debugger. The diagnosis() function, shown below, is a callback

that serves as a breakpoint for the debugger:

#pragma include_assembly_file “checksum.ns”

extern unsigned Checksum(unsigned, const char*);

void TestCall(void) {

unsigned cs;

cs = Checksum(8, “ABCDEFGH”);

}

// set breakpoint here

void diagnosis(unsigned currentChecksum,

unsigned remainingSize,

const char* remainingData) {

}

#pragma ignore_notused currentChecksum

#pragma ignore_notused remainingSize

#pragma ignore_notused remainingData

#pragma ignore_notused diagnosis

The #pragma ignore_notused directives allow the compiler to ignore the

warnings that it otherwise generates for unused variables and functions. The

compiler would generate warnings for these variables and the function because

the compiler is not aware of the embedded assembly code, because the assembly

code is already compiled.
See Calling a Neuron C Function from Assembly Code for a description of this

diagnosis() function.
Another debugging technique is to use dedicated global variables that report

status details which are internal to the assembly function. Because they are

global variables, you can access them from your Neuron C program. This

technique is especially useful for assembly functions that do not complete at once.

For example, a state machine typically runs repeatedly until it returns to an idle

state.
It is also strongly recommended that you follow strict and thorough stack

commenting policies (a recommended policy is described in Documenting Changes

to the Stack). Although thorough stack commenting does not help in debugging a

problem, it is a principal tool to help avoid the need for debugging.

Neuron Assembly Language Reference

45