Skip to content

Commit

Permalink
Add LCD FPS testing utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Juhász Dániel committed Oct 6, 2022
1 parent 7c4afd1 commit e84e8ca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/board_hd44780/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
47 changes: 47 additions & 0 deletions examples/board_hd44780/atmega48_fps_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#undef F_CPU
#define F_CPU 16000000

#include <avr/io.h>

#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++;
}
}
8 changes: 6 additions & 2 deletions examples/board_hd44780/charlcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e84e8ca

Please sign in to comment.