diff --git a/examples/board_hd44780/Makefile b/examples/board_hd44780/Makefile index 9666fa0a8..23a4f5229 100644 --- a/examples/board_hd44780/Makefile +++ b/examples/board_hd44780/Makefile @@ -33,9 +33,10 @@ LDFLAGS += -lpthread include ../Makefile.opengl -all: obj atmega48_charlcd.axf ${target} +all: obj atmega48_charlcd.axf atmega48_fps_test.axf ${target} atmega48_charlcd.axf: atmega48_charlcd.c +atmega48_fps_test.axf: atmega48_fps_test.c include ${simavr}/Makefile.common diff --git a/examples/board_hd44780/atmega48_fps_test.c b/examples/board_hd44780/atmega48_fps_test.c new file mode 100644 index 000000000..f862a44a8 --- /dev/null +++ b/examples/board_hd44780/atmega48_fps_test.c @@ -0,0 +1,47 @@ +#undef F_CPU +#define F_CPU 16000000 + +#include + +#include "avr_mcu_section.h" +AVR_MCU(F_CPU, "atmega48"); + +#include "avr_hd44780.c" + +int main() +{ + hd44780_init(); + /* + * Clear the display. + */ + hd44780_outcmd(HD44780_CLR); + hd44780_wait_ready(1); // long wait + + /* + * Entry mode: auto-increment address counter, no display shift in + * effect. + */ + hd44780_outcmd(HD44780_ENTMODE(1, 0)); + hd44780_wait_ready(0); + + /* + * Enable display, activate non-blinking cursor. + */ + hd44780_outcmd(HD44780_DISPCTL(1, 1, 0)); + hd44780_wait_ready(0); + + uint16_t count = 0; + while (1) + { + uint16_t temp = count; + for (uint8_t i = 5; i > 0; i--) + { + hd44780_outcmd(HD44780_DDADDR(i - 1)); + hd44780_wait_ready(0); + hd44780_outdata(temp % 10 + 48); + temp /= 10; + hd44780_wait_ready(0); + } + count++; + } +} \ No newline at end of file diff --git a/examples/board_hd44780/charlcd.c b/examples/board_hd44780/charlcd.c index 4b69964c2..085e15382 100644 --- a/examples/board_hd44780/charlcd.c +++ b/examples/board_hd44780/charlcd.c @@ -146,11 +146,15 @@ main( char *argv[]) { elf_firmware_t f = {{0}}; - const char * fname = "atmega48_charlcd.axf"; + const char *fname = argc > 1 ? argv[1] : "atmega48_charlcd.axf"; // char path[256]; // sprintf(path, "%s/%s", dirname(argv[0]), fname); // printf("Firmware pathname is %s\n", path); - elf_read_firmware(fname, &f); + if (elf_read_firmware(fname, &f) == -1) + { + fprintf(stderr, "Unable to load firmware from file %s\n", fname); + exit(EXIT_FAILURE); + }; printf("firmware %s f=%d mmcu=%s\n", fname, (int) f.frequency, f.mmcu);