COrnell Miniature ATmel Operating System (COMATOS)

UART and Debugging Facilities

COMATOS includes some debugging features, which can be made available by passing the DEBUG flag to OSInit. Upon being passed this flag, OSInit initializes the UART to 9600bps.

DinkyBug Utility

Because of the complexities and overhead involved in formatting register dumps and other debugging messages, these tasks are best performed by the PC. The DinkyBug utility translates debugging flags from the MCU into more presentable messages. For example, when the MCU performs a register dump, it sends the flag character 0xfc to the PC, followed by 32 bytes of register values. The register values are formatted neatly and displayed on the screen.

The debugging messages which can be identified by DinkyBug are as follows.

DinkyBug will also accept any non-debugging data from the MCU. It also allows the user to send characters back to the MCU.

To use DinkyBug, run the executable with a command line argument specifying the I/O address of the serial port. For example, COM2 is usually at address 0x2f8. Thus, one would type:

DinkyBug 2f8


Register Dumping with OSRegDump

It is often useful to view the state of the registers when debugging real-time systems. The OSRegDump call sends all 32 registers to the UART. The output can be read through the DinkyBug utility. Be aware that this is a blocking call. That is, no scheduling or task execution occurs while the registers are being dumped. Since a call to OSRegDump is made inside a task, the time spent dumping the registers counts in the OS timeout limit. If the timeout value is less than 28 ms per call to OSRegDump, the system will halt during the task. Be sure to set the timeout value appropriately when initializing the OS using OSInit.



UART String Output

UART string output can be performed easily using the OSUARTWait call, which transfers a string from the SRAM to the UART. Because this function was designed to send anything from text output to register dumps, it does not use a flag character to denote the end of the string. Instead, the user must place the number characters to be printed is stored in a special memory location, OSUARTCharCnt. The call itself takes as its only argument a register containing the first character to print. The Z pointer must be aimed at the subsequent characters to print. For an example, see the description of OSUARTWait in the API.

Please be aware that this call is blocking. The actual function is a wait loop which continues until the UART transmit empty ISR sets the txdone bit in OSStatus. Because this call is blocking, any time spent sending a string to the UART is timed by the OS timeout timer. If the value of OSMaxTimout, as set by OSInit, is shorter than the time taken to transmit the string, the system will halt.