LED.
220 Ohm resistor.
Wire.
cmdlinetest.c from sixcode/examples
under:
// functions
add:
void flashLED(void);
in:
int main(void)
add:
// configure port C for led output
outb(DDRC, 0xFF);
// all LEDs on
outb(PORTC, 0x00);
// wait for hardware to power up
timerPause(100);
// all LEDs off
outb(PORTC, 0xFF);
in:
void goCmdline(void)
after:
// add commands to the command database
cmdlineAddCommand("exit", exitFunction);
cmdlineAddCommand("help", helpFunction);
cmdlineAddCommand("dumpargs1", dumpArgsStr);
cmdlineAddCommand("dumpargs2", dumpArgsInt);
cmdlineAddCommand("dumpargs3", dumpArgsHex);
add:
cmdlineAddCommand("flash", flashLED);
in:
void helpFunction(void)
after:
rprintf("dumpargs1 - dumps command arguments as stringsrn");
rprintf("dumpargs2 - dumps command arguments as decimal integersrn");
rprintf("dumpargs3 - dumps command arguments as hex integersrn");
add:
rprintf("flash - flash LEDs attach to PORT Crn");
at bottom of program
add:
void flashLED(void)
{
// all LEDs on
outb(PORTC, 0x00);
// time to keep light on
timerPause(100);
// all LEDs off
outb(PORTC, 0xFF);
}
5. Open the terminal program, turn on your processor in bootloader mode, and send it the text file cmdlinetest.hex. The program should finish with
XXXX bytes written to FLASH with 00 errors.
And you know the program was uploaded successfully.
6. Restart your processor and see if your program controls the light.
7. Modify this program for some more interesting behavior. For instance, you could separate lightOn and lightOff to be two separate commands. Or you could control more than one light with the processor. I have seven-segment displays in the lab, if you want to try writing alphanumeric data to a display. You could also incorporate basic input (with a switch) to trigger behavior. Look at sixcode/examples/basic_io for a dscription of input and output settings for the microcontroller.
7b. Modify the makefile (and rename you directory, your header files, and your source code) so that the program compiles under a different name.
You don't really want to call it cmdlinetest, do you?
2 comments:
If you're having problems...
In the terminal:
"cd \sixcode"
as opposed to
"cd /sixcode"
then,
mkdir twomey.
It felt unreasonably good seeing the led go on and off.
LOVELY.
Post a Comment