Skip to content

TLI_ISR

gicking edited this page Feb 10, 2018 · 3 revisions

back to Command Reference / Interrupt

Description

Implementation of top-level pin interrupt (TLI). Note that, in contrast to port interrupts, a TLI acts only per pin.

If TLI interrupt is enabled for a pin, interrupt service routine TLI_ISR() is automatically called if the selected edge is detected on the pin.

Generally only one pin of an STM8 is TLI interrupt capable. See respective device datasheet for details.

Notes:

  • to enable the TLI interrupt, the respective pin has be configured as INPUT_INTERRUPT or INPUT_PULLUP_INTERRUPT via pinMode() or portMode()
  • edge sensitivity is configured via configEdgeTLI()
  • global interrupts must also be enabled, see interrupts()

Inclusion

  • defined in stm8_interrupt_vector.h
  • auto-loaded in main_general.h
  • in config.h set #define USE_TLI_ISR

Syntax

ISR_HANDLER(TLI_ISR, TLI_VECTOR)

Parameters

  • input:

    • none
  • output:

    • none

Returns

  • Nothing

Example Code

The below code counts the number of falling edges on TLI pin PD7 (without debounce).

#include "main_general.h"

uint16_t   count=0;

ISR_HANDLER(TLI_ISR, __TLI_VECTOR__)
{
  count++;
}

void setup()
{
  noInterrupts();
  configEdgeTLI(FALLING);
  pinMode(&PORT_D, 7, INPUT_PULLUP_INTERRUPT);
  interrupts(); 
}

void loop()
{
  // dummy
}

Relevant Tutorial

Notes and Warnings

  • before changing the edge sensitivity, globally disable interrupts via noInterrupts(). Re-enable them afterwards via interrupts().
  • to use TLI the respective pin must also be configured as INPUT_INTERRUPT or INPUT_PULLUP_INTERRUPT via pinMode() or portMode()

To avoid damage

  • do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
  • for OUTPUT pins assert that sink and source currents are below the specificied limits
  • do not directly connect two OUTPUT pins. If e.g. half-duplex is required, use a pull-up and OUTPUT_OPENDRAIN, instead

See also

Clone this wiki locally