Code Monkey home page Code Monkey logo

stm8s-sdcc-examples's Introduction

STM8S examples using SDCC

There’s not a great number of useful examples for the stm8s chips that use sdcc. This repository aims to fix this. The examples are currently targeting the STM8S103F3P6 and were tested with the according dev board that is available online for <1$.

Resources

Run

  1. You’ll need a programmer, e.g. stlink-v2 or the esp8266-based esp-stlink
  2. Get stm8flash.
$ make
$ stm8flash -c stlinkv2 -p stm8s103f3 -w led.ihx

Examples

LED & Timer

led.c sets up a timer and uses the onboard LED to blink in defined intervals.

Serial

serial.c demos using the UART to transmit serial data.

Interrupts

  • serial_interrupt.c sets up an interrupt handler to perform serial transmission without busy wait.
  • gpio_interrupt.c wakes up from halt mode via external gpio interrupt on B4.

PWM

sound.c uses a timer and an interrupt to create 8-bit PWM output on a pin. You can directly attach a speaker and will hear a low-volume tone:

Oscilloscope View of PWM output

For better sound-quality add a 2.2μF capacitor to GND as a low-pass filter:

Oscilloscope View of PWM output with capacitor

stm8s-sdcc-examples's People

Contributors

lhoyosm avatar rumpeltux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.