Coder Social home page Coder Social logo

hast's Introduction

HAST

Software Defined High-speed Asynchronous Serial Transmitter

HAST is a C++11 template that generates a transmitter routine for a software UART. It deploys unrolled loop with variable padding technique for generating precise timing between bits, and a short sequence (3 cycles) for driving the output. Such approach allows baud rates up to CLOCK/3.

Usage

HAST is a header-only library. Include hast.hpp and instantiate hast::avr::trasmitter as the following

#include "hast.hpp"

void hast_putc(char c) {
	hast::avr::transmitter<
		1000000,							/* 1 MHz			*/
		hast::_115200,					/* 115200 baud	*/
		ADDR_OF(PORTB), PORTB3, 0,	/* pin PORTB3	*/
		hast::stopbits::one			/* one stop bit	*/ 
	>::send(c);
}

Notes

Clock error

Built-in RC-oscillator is calibrated for certain conditions. If operating conditions differ, RC-oscillator may deviate from the expected frequency. This deviation may have negative impact on HAST operations. To improve results, you may need fine tune the RC-oscillator.

Timing table

Baudrate 921600, clock 8 MHz

# start
μs
finish
μs
start
cycles
finish
cycles
wait
cycles
error
μs
err %
0 0 8680 0 9 6 320 3.7%
1 8680 17360 9 17 5 360 4.1%
2 17360 26040 17 26 6 40 0.5%
3 26040 34720 26 35 6 280 3.2%
4 34720 43400 35 43 5 400 4.6%
5 43400 52080 43 52 6 80 0.9%
6 52080 60760 52 61 6 240 2.8%
7 60760 69440 61 69 5 440 5.1%
8 69440 78120 69 78 6 120 1.4%
9 78120 86800 78 87 7 200 2.3%

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.