110 likes | 457 Views
Embedded Systems Education at NC State University. Alex Dean Dept. of ECE alex_dean@ncsu.edu. Overall Goals. Teach students how MCUs are different from MPUs how to use the peripherals how to write efficient C code how to debug for function and performance
E N D
Embedded Systems Education at NC State University Alex Dean Dept. of ECE alex_dean@ncsu.edu
Overall Goals • Teach students • how MCUs are different from MPUs • how to use the peripherals • how to write efficient C code • how to debug for function and performance • Provide students with hands-on experience • Give them a development kit which they can build on in the future • Collaborators • Suleyman Sair • Jim Conrad (UNC-Charlotte)
Curriculum Overview ECE 206 – Intro. to Computer Organization -Microprocessor Concepts -Assembly Language Programming (LC-3) -C Programming ECE 212 – Digital Logic Design ECE 406 – Design of Complex Digital Systems • ECE 306 – Introduction to Embedded Systems • Introduction to Microcontrollers • Embedded SW/HW Development and Debugging • Multithreaded Programming ECE 463 – Computer Design and Technology • ECE 492D/561 – Embedded System Design • -Software Design • Software Analysis • C Compiler Use Expertise ECE 460 – Digital Systems Interfacing Hardware Design Focus ECE 481 – Senior Design
ECE 306 – Introduction to Embedded Systems • Goal: • Familiarity with microcontroller programming in C • Know how to use peripherals • Have a gut feeling for time and memory impact of C features • my own compiler bias... • Mechanics • MCU Renesas SKP16C26, M16C architecture • 16-bit CISC, 64 kB FLASH ROM, 2 kB SRAM, 2x8 LCD, • Tool chain • IDE with C compiler, assembler, linker, on-chip debugger • Tools never expire • Low-cost ($50-$100). Students buy boards, develop code on own PCs. • Lab with DSOs and PCs for office hours, debugging and demos • Core course for Computer Engineering majors • 125 students in fall, 75 in spring, some even in summer
2. SP 1. Old FB y x z 2. FB Return Adx. a b c 306 Topics • M16C ISA • Instruction set • Addressing modes • How C is implemented in assembly language • Memory sections • Subroutine call mechanism • Call stack and activation records • CRT0 introduction • C Stdlib Emulation • Interrupts • Vectors • ISRs ########################################## # (2) SECTION INFORMATION # ########################################## # SECTION ATR TYPE START LENGTH ALIGN MODULENAME data_SE ABS DATA 000400 000000 NCRT0_UART bss_SE REL DATA 000400 000000 2 NCRT0_UART data_SO REL DATA 000400 000000 NCRT0_UART bss_SO REL DATA 000400 000000 NCRT0_UART data_NE REL DATA 000400 000000 2 NCRT0_UART REL DATA 000400 000014 GLOBALS REL DATA 000414 000002 ERRNO REL DATA 000416 00000C INFINITY bss_NE REL DATA 000422 000000 2 NCRT0_UART REL DATA 000422 000218 GLOBALS REL DATA 00063A 000004 SPRINTF REL DATA 00063E 000108 PRINT data_NO REL DATA 000746 000000 NCRT0_UART bss_NO REL DATA 000746 000000 NCRT0_UART REL DATA 000746 00026A PRINT stack REL DATA 0009B0 000200 NCRT0_UART heap REL DATA 000BB0 000000 NCRT0_UART etc…..
306 Topics • Peripherals • GPIO, ADC, DAC, Timer, UART+RS232, WDT • Schedulers • Run-to-completion scheduler • Simple: core ~20 lines of code • Used in projects • Preemptive • Context switching • Kernel activity • Task states, intertask synchronization • Fixed-point and floating point math • Digital oscilloscope • Debugging and performance (timing) analysis
Write Read Data from SRAM Data from MCU D7-D0 Adx from MCU Adx from MCU A15-A0 ~WR ~RD RDY/BSY FLASH MEMORY ARRAY RESET PAGE SIZE = BUFFER SIZE WP BUFFER 2 BUFFER 1 SCK CS I/O INTERFACE SI SO 306 Topics • External memory interfacing • Parallel • Serial (DataFlash) • Good coding practices • Modular programming • Incremental testing and debugging • Software testing • Run-time robustness • Watchdog Timer • Stack Pointer monitor • Data structure health checks • Voltage brown-out detector
306 Lab Projects • Digital voltmeter • Hardware and software voltage-controlled oscillators • Digital sampling oscilloscope • Etch-a-sketch • et cetera
ECE 561 • Goals • Once again, gut feeling for how C code will be implemented • How to squeeze the best performance from the compiler • Techniques to analyze complex software • Techniques to guarantee real-time performance • Mechanics • Renesas M16C architecture (16-bit): labs • Atmel AVR architecture (8-bit): optional for final project • ARM7 Architecture (32-bit): optional for final project
Cycle Counts +2 for taken conditional jump 22 _timer_isr 8 4 L0 _timer_isr_0 55 L1 561 Topics • Code analysis basics • Control flow graphs • Call graphs • Static timing analysis • C Compiler • C run-time environment initialization • How to stay out of the optimizer’s way • C type promotion rules for expressions • Real-time systems • Worst-case execution timing analysis • Scheduling • Response time analysis
main SMax=9 bytes C=9 bytes f1 SMax=11 bytes C=20 bytes Normal 16.5 mW 5.5 mA 250 ns 250 ns __i4tof4 SMax=21 bytes C=41 bytes __f4mul SMax=40 bytes C=60 bytes 250 ns var. var. 1.75 ms Idle 4.8 mW 1.6 mA Power-Down 0.003-0.030 mW 0.001-0.010 mA Power-Save 0.009 mW 0.003 mA __ltof SMax=15 bytes C=56 bytes __f4lto4 SMax=11 bytes C=52 bytes 561 Topics • Profiling through PC sampling • Scheduler Instrumentation • Stack size bounding • Analytical • Approximate (high-water-marking) • Hardware reliability • Software reliability: testing, defensive programming • Energy and power • CMOS power dissipation • Idle modes • DFS and DVS • Predicting energy use