Skip to content

Device headers and examples for STM8 microcontrollers

License

Notifications You must be signed in to change notification settings

gicking/STM8_headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM8 Device Headers

Open-Sources device headers for all STM8 microcontroller series, namely STM8A, STM8S, STM8L, STM8AF and STM8AL.

Device headers

XML Device Description

Headers were generated from device descriptions in XML format, which are in folder XML. These descriptions could be used e.g. for a graphical debugger interface.

Related Projects

The below projects have been ported to use these open-sources device headers for STMo.

atomthreads

Example Projects

These projects have been tested successfully with SDCC, Cosmic and IAR.

adc1_scan

  • perform an ADC1 scan of AIN0..AIN3 every 1ms
  • read result in TIM4 ISR and trigger next scan
  • send result every 1s

adc_continuous_1ch

  • measure 1 channel continuously
  • read ADC value in timer ISR every 1ms
  • every 500ms print ADC value via UART using printf()
  • works with ADC1 (advanced) & ADC2 (basic)

adc_single-shot_1ch

  • measure 1 channel every ~500ms in single shot mode
  • print value via UART using printf()
  • works with ADC1 (advanced) & ADC2 (basic)

beeper

  • activate beeper output via option bytes
  • generate different frequencies on BEEP pin
  • no LSI calibration (yet)
  • no interrupts

benchmark_biquad

  • benchmark for comparison of Biquad algorithms performance

blink_interrupt

  • blink LED in TIM4 interrupt service routine

blink_noInterrupt

  • blink LED with a simple NOP() loop

calculate_CRC

  • periodically calculate CRC over pre-defined data
  • measure time for CRC calculation
  • print time and calculated CRC to UART
  • CRC32 code copied from https://github.com/basilhussain/stm8-crc
  • SDCC uses optimized assembler, IAR and Cosmic C implementation

CLI_console


clock_switch

  • periodically:
    • switch between internal and external clock with timeout
    • print active clock via UART
  • for extra safety use independent watchdog (IWDG)

I2C_LCD

  • Periodically print text to 2x16 char LCD attached to I2C
  • LCD type Batron BTHQ21605V-COG-FSRE-I2C 2X16 (Farnell 1220409)

IWDG_watchdog

  • initialize IWDG to 100ms, service every 50ms
  • print millis to UART every 500ms
  • if 'r' received, stop watchdog service --> reset

low-power_auto-wake

  • enter power-down mode with wake via port-ISR or AWU

millis_delay

  • implement 1ms ISR, millis(), micros() etc., similar to Arduino

Modbus_RTU


Modbus_RTU_auto-address

  • small Modbus RTU client implementation to demonstrate auto-addressing
  • demonstrate detection of colliding Modbus IDs and resolving the issue
  • see corresponding Python server in Utils

pin_interrupt

  • TLI interrupt on pin D7 (not port). Corresponds to INTx on Arduino

pin_read_write

  • read and write pin states without interrupts

port_interrupt

  • port interrupt on pin PE5. Corresponds to port change interrupts on Arduino

PWM_2ch_phase-shift

  • configure timer 1 for up-down counter with 50kHz frequency
  • generate 2x PWM on TIM1_CH1 and TIM1_CH3
  • ramp up/down duty cycle

PWM_generate

  • generate a PWM on pin PD2/TIM3_CH1 (=pin 3 on sduino)

read_unique_ID

  • read unique identifier and print via UART
  • Note: UID not supported by all devices

read_write_D-flash

  • save data to D-flash/EEPROM and read back

read_write_option_bytes

  • change option bytes, e.g. activate/deactivate the ROM-bootloader

read_write_P-flash

  • save data to P-flash and read back

serial_gets_printf

  • serial input/output with gets and printf
  • without interrupts or FIFO

serial_printf

  • serial output via printf
  • without interrupts or FIFO

serial_printf_FIFO_interrupt

  • serial output via printf
  • using Tx & Rx FIFO and interrupts
  • similar to Arduino Serial class

serial_write

  • echo read bytes from UART
  • without interrupts or FIFO

Single-Wire_DS18B20


SPI_LED_MAX7219


STM8_StdPeriphLib

  • mix with functions/headers of the STM8S Standard Peripheral Library (SPL)
  • SDCC compatibility requires patch, see e.g. here.

Task_Scheduler

About

Device headers and examples for STM8 microcontrollers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages