Example now enables the serial RX interrupt for echo

This commit is contained in:
2025-09-21 11:10:53 +02:00
parent 2a88835da5
commit cf04037f9d

View File

@@ -187,7 +187,8 @@ void timer_init(void) {
// Enable interrupts only for timer 0
IE = 0x82;
EA = 1;
ET0 = 1;
}
// Initializes the serial port (along with timer 2).
@@ -202,12 +203,14 @@ void serial_init(void) {
SCON = 0x50;
TI = 1;
ES = 1;
}
// Writes a character to the serial port.
void serial_putchar(char c) {
while(TI == 0);
SBUF = c;
TI = 0;
}
__bit stdout_to_lcd = 0;
@@ -317,3 +320,11 @@ void timer0_handler(void) __interrupt(1) {
if(TIMER != 0) TIMER--;
}
void serial_hanlder(void) __interrupt(4) {
if(RI) {
uint8_t data = SBUF;
serial_putchar(data);
RI = 0;
}
}