From 2a88835da5db7d52963b55ffe27f931461a9ce22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Proch=C3=A1zka?= Date: Sun, 21 Sep 2025 10:56:15 +0200 Subject: [PATCH] Massively sped up LCD comms --- example.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/example.c b/example.c index 183fd8f..ff45120 100644 --- a/example.c +++ b/example.c @@ -13,7 +13,7 @@ #include #define TICK_RATE 100 -#define NPER (0x10000 - (20000000 / 12 / TICK_RATE)) +#define NPER (0x10000 - (20000000 / 6 / TICK_RATE)) // I/O definitions #define BUTTON_1 P3_2 @@ -64,8 +64,7 @@ uint8_t lcd_pos; // Quick'n'dirty CPU pause, just enough for the LCD to stabilize. void lcd_pause(void) { - int i = 30; - while(i--); + __asm__ ("nop"); } // Reads the status register from the LCD. @@ -174,6 +173,8 @@ void lcd_putchar(char c) { // Initializes the background tick timer (for delays). void timer_init(void) { + CKCON0 = X2; // Enable 2x clock mode + // Initialize timer 0 as 16-bit countdown, timer 1 as 8-bit auto-reload countdown TMOD = 0x21; @@ -194,7 +195,7 @@ void serial_init(void) { // Initialize timer 2 as 312500 Hz as the baud rate generator (for tulflash) RCAP2H = 0xFF; - RCAP2L = 0xFE; + RCAP2L = 0xFC; T2CON = 0x34; // Initialize serial I/O @@ -286,6 +287,8 @@ void main(void) { lcd_init(); serial_init(); + delay(1); + stdout_to_serial = 1; stdout_to_lcd = 1;