Massively sped up LCD comms

This commit is contained in:
2025-09-21 10:56:15 +02:00
parent aa84a2c03b
commit 2a88835da5

View File

@@ -13,7 +13,7 @@
#include <stdint.h>
#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;