Skip to content

UART234_RXF_ISR

gicking edited this page Feb 10, 2018 · 1 revision

back to Command Reference / Interrupt

Description

Implementation of the shared UART2/3/4 receive buffer full (RXF) interrupt service routine for background reception (see Serial). If UART234 receive interrupt is enabled via UARTx_enable_receive_interrupt(), interrupt service routine UART234_RXF_ISR() is automatically called when a byte is received via UART2, UART3 or UART4.

Notes:

Inclusion

  • defined in stm8_interrupt_vector.h
  • auto-loaded in main_general.h
  • in config.h set #define USE_UART234_RXF_ISR, and implement the interrupt routine UART234_RXF_ISR

Syntax

ISR_HANDLER(UART234_RXF_ISR, UART234_RXF_VECTOR)

Parameters

  • input:

    • none
  • output:

    • none

Returns

  • Nothing

Example Code

The below code echoes bytes received via UART2 in interrupts. After byte is sent, an LED toggles.

#include "main_general.h"
#include "uart2.h"

ISR_HANDLER(UART234_RXF_ISR, __UART234_RXF_VECTOR__) {
  UART2_write(UART2_read());
  UART2_enable_send_interrupt();
}

ISR_HANDLER(UART234_TXE_ISR, __UART234_TXE_VECTOR__) {
  pinToggle(&PORT_H, 3);
  UART2_disable_send_interrupt();   // important!
}

void setup() {
  UART2_begin(115200);
  UART2_enable_receive_interrupt();
  pinMode(&PORT_H, 3, OUTPUT);
}

void loop() {
  // do something else
}

Relevant Tutorial

See also

Clone this wiki locally