Pushing a button
The ability to waggle a pin low and high via a mouse click in the debugger and read its state in a program may seem somewhat unexciting, but it's a start for me. Looking at some of the other examples in the RealView Microcontroller Development Kit, I note that there are several that use buttons that appear in a window called the "Toolbox". A button that I can push to waggle the pin is exactly what I am looking for.
The Traffic example contains a button that allows me to simulate the "Push to walk" button at a crosswalk. Whenever I start the debugger and simulation for this example some commands and C-like code get loaded into the debugger at startup. These are shown scrolling past on the debugger's output window. But where do these commands come from? A quick grep of the Traffic example's directory for one of the strings that scrolled past and I find that the Traffic example has a .ini file that contains the debugger commands. Interesting...
Digging a little further, I find that the project options allow me to specify that a .ini file is executed when the debugger session commences. This is neat as it enables me to consistently set up my debug world with breakpoints, watchpoints, etc. whenever I start debugging. Moreover, it enables me to define buttons!
The .ini file for Traffic looks like this:
PORT0 = 0x4000; /* set P0.14 low: Key Input */Hmmm... I think they mean high here!
/* define a debug function for
the pedestrian push button */
signal void push_key (void) {
PORT0 &= ~0x004000; /* set P0.14 low */
swatch (0.05); /* wait 50 msec */
PORT0 = 0x004000; /* set P0.14 high */
}
/* define a toolbar button to call push_key */
define button "Push for Walk", "push_key ()"
...



0 Comments:
Post a Comment
<< Home