aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Petru Chircu Mare <[email protected]>2025-11-06 21:51:56 -0800
committerBogdan Petru Chircu Mare <[email protected]>2025-11-06 21:59:12 -0800
commita71eff2e1cea55b393e793c023b8e51e5cc369a1 (patch)
treef0da4690f72e79681396d8231449cdde1347ea8d
parent4fcc74dbd3906db35a56dc179b08b23bfd5bdffa (diff)
Fix uart_interrupt example: enable RX interrupts in peripheral
The uart_interrupt example was not echoing received characters because the RX interrupt enable bit (RIE) was not being set in the LPUART control register. The NVIC interrupt was configured and the handler was installed, but the peripheral itself was not generating interrupts. Added uart.enable_rx_interrupts() call to enable RX data interrupts in the LPUART2 peripheral before entering the main loop.
-rw-r--r--README.txt4
-rw-r--r--examples/uart_interrupt.rs4
2 files changed, 7 insertions, 1 deletions
diff --git a/README.txt b/README.txt
index 80fa81b07..ae80ca8ef 100644
--- a/README.txt
+++ b/README.txt
@@ -287,6 +287,10 @@ probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-non
287probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/rtc_alarm 287probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/rtc_alarm
288probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/adc_polling 288probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/adc_polling
289probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/adc_interrupt 289probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/adc_interrupt
290probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/ostimer_alarm
291probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/ostimer_async
292probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/ostimer_counter
293probe-rs run --chip MCXA276 --protocol swd --speed 1000 target/thumbv8m.main-none-eabihf/debug/examples/ostimer_race_test
290``` 294```
291 295
292How I tested on Windows 296How I tested on Windows
diff --git a/examples/uart_interrupt.rs b/examples/uart_interrupt.rs
index b309ce973..85743bb64 100644
--- a/examples/uart_interrupt.rs
+++ b/examples/uart_interrupt.rs
@@ -45,9 +45,11 @@ async fn main(_spawner: Spawner) {
45 // Configure LPUART2 interrupt for UART operation BEFORE any UART usage 45 // Configure LPUART2 interrupt for UART operation BEFORE any UART usage
46 hal::interrupt::LPUART2.configure_for_uart(hal::interrupt::Priority::from(3)); 46 hal::interrupt::LPUART2.configure_for_uart(hal::interrupt::Priority::from(3));
47 47
48 // Manually install the interrupt handler 48 // Manually install the interrupt handler and enable RX IRQs in the peripheral
49 unsafe { 49 unsafe {
50 hal::interrupt::LPUART2.install_handler(lpuart2_handler); 50 hal::interrupt::LPUART2.install_handler(lpuart2_handler);
51 // Enable RX interrupts so the handler actually fires on incoming bytes
52 uart.enable_rx_interrupts();
51 } 53 }
52 54
53 // Print welcome message 55 // Print welcome message