@databasescaling Wednesday, 18 th April 2013

Similar documents
Getting Started with the Texas Instruments ez430

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

CPE/EE 323 Introduction to Embedded Computer Systems Homework V

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B

Timers and Clocks CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)

ECE PRACTICE EXAM #2 Clocks, Timers, and Digital I/O

Block diagram of processor (Harvard)

Alex Milenkovich 1. CPE/EE 421 Microcomputers: The MSP430 Introduction. Outline

CPE 323: MSP430 Timers

ARDUINO MEGA INTRODUCTION

ECE2049: Embedded Computing in Engineering Design C Term Spring 2019 Lecture #22: MSP430F5529 Operating Mode & the WDT

Name: Clint Furrer Project Number: TI003 Project Description: Safety Walking Lights. Description:

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #7: More Digital IO

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory

MSP430. More on MSP430

CONTENTS: Program 1 in C:

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

MIDTERM#1. 2-(3pts) What is the difference between Von Neumann & Harvard processor architectures?

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -2 1 UNIT 2

Lab 1: I/O, timers, interrupts on the ez430-rf2500

Lecture test next week

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #8: Making it work: LEDs, Buttons & Keypad

Texas Instruments Microcontroller HOW-TO GUIDE Interfacing Keypad with MSP430F5529

File: /media/j/texas/my msp430/g3tr/g3tr.c Pagina 1 di 5

Installation tutorial for the Skomer IDE

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Getting Started with the MSP430 LaunchPad

ARM Architecture and Assembly Programming Intro

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller

Texas Instruments Mixed Signal Processor Tutorial Abstract

AVR Microcontrollers Architecture

Electronics Single Board Computers

Using peripherals on the MSP430 (if time)

STM32F3. Cuauhtémoc Carbajal ITESM CEM 12/08/2013

Why embedded systems?

Getting Started with the MSP430 LaunchPad

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #11: More Clocks and Timers

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

Sanguino TSB. Introduction: Features:

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Farklı Arduino Boardlar

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

What is an Interrupt?

MSP430 Interrupts. Change value of internal variable (count) Read a data value (sensor, receive) Write a data value (actuator, send)

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter

Lab 1 Introduction to Microcontroller

// Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz #define Bitime_5 0x05*4 // ~ 0.5 bit length + small adjustment #define Bitime 13*4//0x0D

Embedded Technosolutions

EE 308: Microcontrollers

Low-Cost Microcontrollers

8051 Microcontroller

Memory Architectures. Hongwei Zhang. Chapter 9

Linking. Explain what ELF format is. Explain what an executable is and how it got that way. With huge thanks to Steve Chong for his notes from CS61.

EEL 4924 Electrical Engineering Design (Senior Design) Team Baudiophile. Wireless Headphones

Using Code Composer Studio IDE with MSP432

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

Systems Programming. Lecture 4 Z16 Architecture and Programming

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II

Introducing STM32 L0x Series. April

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

MSP-430 Host Software Example for the QF4A512

COL862 - Low Power Computing

Microcontroller: CPU and Memory

Team 3. By: Miriel Garcia. Microcontrollers/ TI MSP430F5438A. ECE 480 senior Design. Application Note 4/3/15

CPE 323 Introduction to Embedded Computer Systems: ADC12 and DAC12. Instructor: Dr Aleksandar Milenkovic Lecture Notes

PROGMEM ESP8266EX RAM

Enabling IoT OSs for Intel Quark MCU Platforms: the fast way. OpenIoT Summit Europe Andre Guedes

ECE2049-E17 Lecture 6 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

Wireless Sensor Networks (WSN)

Interrupts, Low Power Modes

LAB1. Get familiar with Tools and Environment

Embedded programming, AVR intro

Lecture 5: MSP430 Interrupt

Microcontroller Basics

C Language Programming through the ADC and the MSP430 (ESCAPE)

Getting Started in C Programming with Keil MDK-ARM Version 5

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

Getting Started in C Programming with Keil MDK-ARM Version 5

(Embedded) Systems Programming Overview

Introduction to ARM LPC2148 Microcontroller

ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O

Basic Components of Digital Computer

Interconnects, Memory, GPIO

Interrupts CS4101 嵌入式系統概論. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

STM8L and STM32 L1 series. Ultra-low-power platform

USB Connectivity using MSP430 and TUSB3410

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

ArduCAM-M-2MP Camera Shield

AN5123 Application note

Kinetis Bootloader to Update Multiple Devices in a Field Bus Network

Introduction to Arduino

Getting Started in C Programming with Keil MDK-ARM Version 5

CN310 Microprocessor Systems Design

MICROPROCESSOR BASED SYSTEM DESIGN

CPE 325: Embedded Systems Laboratory Laboratory #9 Tutorial Software Reverse Engineering

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

Transcription:

andyjpb@ashurst.eu.org @databasescaling Wednesday, 18 th April 2013 OSHUG #24 1 / 56

Writing C For Constrained Systems a@jpb.li @databasescaling Wednesday, 18 th April 2013 OSHUG #24 2 / 56

Writing C For Constrained Systems A Morse Code Beacon a@jpb.li @databasescaling Wednesday, 18 th April 2013 OSHUG #24 3 / 56

........... http://thestateofme.files.wordpress.com/2011/09/morse.png OSHUG #24 4 / 56

TI Launchpad http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 5 / 56

TI Launchpad $4.30 http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 6 / 56

MSP430 $4.30 Timers http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 7 / 56

MSP430 $4.30 Timers 8 Channel 10-bit ADC http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 8 / 56

MSP430 $4.30 Timers 8 Channel 10-bit ADC Comparator http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 9 / 56

MSP430 $4.30 Timers 8 Channel 10-bit ADC Comparator I2C, SPI, UART http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 10 / 56

MSP430 $4.30 Timers 8 Channel 10-bit ADC Comparator I2C, SPI, UART General Purpose I/O http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 11 / 56

MSP430 $4.30 Timers 8 Channel 10-bit ADC Comparator I2C, SPI, UART General Purpose I/O Capacitive Sense I/O Ports http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 12 / 56

MSP430 http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 13 / 56

MSP430 16 MHz 16 KB Flash 256 Bytes RAM http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 14 / 56

MSP430 16 MHz 16 KB Flash 512 Bytes RAM 16 MHz 16 KB Flash 256 Bytes RAM http://processors.wiki.ti.com/images/thumb/a/ad/launchpad_wireframe.png/300px-launchpad_wireframe.png OSHUG #24 15 / 56

C http://archive.computerhistory.org/resources/still-image/dec/pdp-8/dec.boy_at_teletype.c1965.102627494.lg.jpg OSHUG #24 16 / 56

Arduino Uno http://arduino.cc/en/uploads/main/arduinouno_r3_front_450px.jpg OSHUG #24 17 / 56

ATMega 328 16 MHz 32 KB Flash 2 KB RAM 1 KB EEPROM http://arduino.cc/en/uploads/main/arduinouno_r3_front_450px.jpg OSHUG #24 18 / 56

Arduino Mega 2560 16 MHz 32 KB Flash 2 KB RAM 1 KB EEPROM http://arduino.cc/en/uploads/main/arduinomega2560_r3_front_450px.jpg http://arduino.cc/en/uploads/main/arduinouno_r3_front_450px.jpg OSHUG #24 19 / 56

Arduino Mega 2560 16 MHz 32 KB Flash 2 KB RAM 1 KB EEPROM 16 MHz 256 KB Flash 8 KB RAM 4 KB EEPROM http://arduino.cc/en/uploads/main/arduinomega2560_r3_front_450px.jpg http://arduino.cc/en/uploads/main/arduinouno_r3_front_450px.jpg OSHUG #24 20 / 56

AT Tiny 2313 http://www.sklep.semics.pl/bilder/attiny.2313v-10su.jpg OSHUG #24 21 / 56

AT Tiny 2313 20 MHz 2 KB Flash 128 Bytes RAM 128 Bytes EEPROM http://www.sklep.semics.pl/bilder/attiny.2313v-10su.jpg OSHUG #24 22 / 56

C http://cm.bell-labs.com/cm/cs/who/dmr/kd14.jpg OSHUG #24 23 / 56

........... http://thestateofme.files.wordpress.com/2011/09/morse.png OSHUG #24 24 / 56

........... 16 MHz 16 KB Flash 256 Bytes RAM http://thestateofme.files.wordpress.com/2011/09/morse.png OSHUG #24 25 / 56

main.c //**************************************************************** // Based on MSP430F20xx Demo - Software Toggle P1.0 // // Description; Sends characters by morse // ACLK = n/a, MCLK = SMCLK = default DCO // // MSP430F20xx // ----------------- // / \ XIN - // // -- RST XOUT - // // P1.0 -->LED // // Chris Swan // September 2011 //**************************************************************** https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 26 / 56

Examples OSHUG #24 27 / 56

main.c void dot(void) { P1OUT = 0x01; // LED on shortpause(); P1OUT = 0x00; // LED off } shortpause(); https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 28 / 56

main.c void dash(void) { P1OUT = 0x01; // LED on shortpause(); // dash is three times longer than dot shortpause(); shortpause(); P1OUT = 0x00; // LED off } shortpause(); https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 29 / 56

main.c void shortpause(void) { volatile unsigned int i; } i = 25000; // Delay do (i--); while (i!= 0); https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 30 / 56

OSHUG #24 31 / 56

main.c void tap_a(void) { dot(); dash(); shortbreak(); } https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 32 / 56

main.c void tap_a(void) { dot(); dash(); shortbreak(); } void tap_b(void) { dash(); dot(); dot(); dot(); shortbreak(); } https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 33 / 56

main.c void tap_a(void) { dot(); dash(); shortbreak(); } void tap_b(void) { dash(); dot(); dot(); dot(); shortbreak(); } void tap_c(void) { dash(); dot(); dash(); dot(); shortbreak(); } https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 34 / 56

-.... / --.-..-.. -.-. -.- / -....-. -- void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR = 0x01; // Set P1.0 to output direction for (;;) { tap_t(); tap_h(); tap_e(); longbreak(); tap_q(); tap_u(); tap_i(); tap_c(); tap_k(); longbreak(); tap_b(); tap_r(); tap_o(); tap_w(); tap_n(); longbreak(); https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 35 / 56

OSHUG #24 36 / 56

$ gcc -c main.c OSHUG #24 37 / 56

TEXT http://nullprogram.com/img/pngarch/bin-ls.png OSHUG #24 38 / 56

TEXT void tap_a(void) { dot(); dash(); shortbreak(); } OSHUG #24 39 / 56

DATA http://www.tutorialspoint.com/images/string_representation.jpg http://www.csse.monash.edu.au/~damian/idioms/topics/01.1.array/html/arrayinternals.gif http://www.plantation-productions.com/webster/www.artofasm.com/aoaextra/hlastrs-2.gif OSHUG #24 40 / 56

DATA char prompt[] = WELCOME> ; char greeting[] = Hello World! ; byte command[] = { start_byte, cmd_type, cmd_id, serial_number, data_length_1, data_length_2, data_byte_1, data_byte_2,., end_byte }; OSHUG #24 41 / 56

BSS http://commons.esipfed.org/sites/all/modules/contrib/media_gallery/images/empty_gallery.png OSHUG #24 42 / 56

BSS char input_buffer[20]; char flag; OSHUG #24 43 / 56

$ gcc -c main.c $ readelf -t main.o OSHUG #24 44 / 56

$ gcc -c main.c $ readelf -t main.o There are 12 section headers, starting at offset 0x938: Section Headers: [Nr] Name Type Address Offset Link Size EntSize Info Align Flags OSHUG #24 45 / 56

$ gcc -c main.c $ readelf -t main.o There are 12 section headers, starting at offset 0x938: Section Headers: [Nr] Name Type Address Offset Link Size EntSize Info Align Flags OSHUG #24 46 / 56

OSHUG #24 47 / 56

$ gcc -c main.c $ readelf -t main.o [ 1].text PROGBITS 0000000000000000 0000000000000040 0 000000000000045d 0000000000000000 0 4 [0000000000000006]: ALLOC, EXEC OSHUG #24 48 / 56

$ gcc -c main.c $ readelf -t main.o [ 1].text PROGBITS 0000000000000000 0000000000000040 0 000000000000045d 0000000000000000 0 4 [0000000000000006]: ALLOC, EXEC OSHUG #24 49 / 56

$ gcc -c main.c $ readelf -t main.o [ 1].text PROGBITS 0000000000000000 0000000000000040 0 000000000000045d 0000000000000000 0 4 [0000000000000006]: ALLOC, EXEC 1,117 Bytes OSHUG #24 50 / 56

$ gcc -c main.c $ readelf -t main.o [ 3].data PROGBITS 0000000000000000 00000000000004a0 0 0000000000000000 0000000000000000 0 4 [0000000000000003]: WRITE, ALLOC OSHUG #24 51 / 56

$ gcc -c main.c $ readelf -t main.o [ 3].data PROGBITS 0000000000000000 00000000000004a0 0 0000000000000000 0000000000000000 0 4 [0000000000000003]: WRITE, ALLOC OSHUG #24 52 / 56

$ gcc -c main.c $ readelf -t main.o [ 4].bss NOBITS 0000000000000000 00000000000004a0 0 0000000000000000 0000000000000000 0 4 [0000000000000003]: WRITE, ALLOC OSHUG #24 53 / 56

$ gcc -c main.c $ readelf -t main.o [ 4].bss NOBITS 0000000000000000 00000000000004a0 0 0000000000000000 0000000000000000 0 4 [0000000000000003]: WRITE, ALLOC OSHUG #24 54 / 56

2500 2000 1500.data / Bytes 1000 500 0 ex1 ex2 ex3 ex4 Example OSHUG #24 55 / 56

How do we fit this into an AT Tiny? Benchmark the tap_* procedures only Put the message in RAM Put the message in EEPROM OSHUG #24 56 / 56

? OSHUG #24 57 / 56

OSHUG #24 58 / 56

Arduino Due The Due has a 32-bit ARM core that can outperform typical 8-bit microcontroller boards. The most significant differences are: A 32-bit core, that allows operations on 4 bytes wide data within a single CPU clock. (for more information look int type page). CPU Clock at 84Mhz. 96 KBytes of SRAM. 512 KBytes of Flash memory for code. a DMA controller, that can relieve the CPU from doing memory intensive tasks. http://arduino.cc/en/uploads/main/arduinodue_front_450px.jpg OSHUG #24 59 / 56

main.c void longbreak(void) { shortbreak(); shortbreak(); } https://github.com/cpswan/ti-launchpad/blob/master/morse/main.c OSHUG #24 60 / 56

Ex1: text: 0x33c, data: 0xf0, bss 0x8 Ex2: text: 60c, data: 0x10, bss: 0x8 Ex3: text: 35c data: 2c, bss: 0x4 Ex4: text: 0x4fc data: 0x10 bss: 0x8 OSHUG #24 61 / 56

Ex1.o: text: 0x187, data: 0xd0 + 0x270, rodata: 9c, bs: 0 Ex2.o: text: 0x462, data: 0 bss: 0 Ex3.o: text: 0x1b2, data: 1a,rodata: 2c, bss: 0 Ex4.o: text: 0x34c, data: 0, rodata 208 + 588 bss:0 OSHUG #24 62 / 56