By: Mostafa El-koumy Day #1 Embedded
Introduction ? o Introduction to Embedded C. o Embedded Software Architecture. o Memory usage. o Embedded Development Environment. o Interrupts. o Keywords. o Some Embedded Systems concepts. By: Mostafa El-koumy
INTRODUCTION  Embedded Systems is all things around you which have something called electronic brain to make some sort of artificial intelligence.  Embedded C is a prober subset of C language suitable for Embedded systems, it defines only a new concept of writing software.  Using Embedded C, we should handle everything used in the program like Memory Management, HW Registers, interrupts, …. Etc. By: Mostafa El-koumy
MISRA RULES  Motor Industry Software Reliability Association.  Collaboration between engineering consultancies which seeks to promote best practice in developing Automotive Systems and other embedded systems.  To this end MISRA publishes documents that provide accessible information for engineers and management, and holds events to permit the exchange of experiences between practitioners.  URL : www.misra.org.uk  EX: By: Mostafa El-koumy
EMBEDDED SOFTWARE ARCHITECTURE By: Mostafa El-koumy
EMBEDDED SOFTWARE ARCHITECTURE (CON’T) By: Mostafa El-koumy
CODE FLOW  All the code is running within infinite loop in main except:  Initialization code.  Interrupt handlers, interrupt service routines (ISR).  The other code runs normally int main (void) { intitializeModule(); sei(); while(1){ startApplication(); } return 0; } By: Mostafa El-koumy
BACKGROUND/FOREGROUND TASKS (LOW COST) By: Mostafa El-koumy
SOFTWARE MODELING Function C file Module Project C file(s) H file(s) SW module Uart.c Uart.h Uart_irq.c Uart_cfg.h
MEMORY USAGE BY LINKER SCRIPT  The HW Registers  Stack space that grow down  Local variables  Functions return address  Heap Space that grow up  Zero default initialized variables  Initialized with value by developer By: Mostafa El-koumy I/O Addresses Stack (grow down) Heap (Grow up) Un-initialized data (.BSS) Initialized data
DEVELOPMENT ENVIRONMENT  IDE which has  Text editor.  Cross compiler produce machine language By: Mostafa El-koumy
DEVELOPMENT ENVIRONMENT  Development Kit By: Mostafa El-koumy
DEVELOPMENT ENVIRONMENT  In circuit Debugger (ICD)  HW device connects to the microprocessor using JTAG/SWD interface to support external control of the microprocessor using debugger.  Restrictions of debugging capabilities is specified by the microprocessor. By: Mostafa El-koumy
DEVELOPMENT ENVIRONMENT  In circuit Emulator (ICE)  HW device used to debug embedded SW. it replaces the microprocessor with control over all the aspects of it and it usually emulate all the microprocessor family. By: Mostafa El-koumy
PROGRAMMING PROCESS DIAGRAM By: Mostafa El-koumy
GPIO MODULE Exercise 1 By: Mostafa El-koumy
INTERRUPTS  an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code the processor is executing.  Interrupt sources  Internal peripherals.  External interrupts.  SW interrupts.  Exception thrown by processors. By: Mostafa El-koumy
INTERACTIVE QUESTIONS  Mask able interrupt?  Non-Mask able interrupts?  Level triggered external interrupt?  Edge triggered external interrupt?  Interrupt nesting? By: Mostafa El-koumy
INTERRUPT TIMING  Interrupt latency?  Context?  Interrupt response?  Interrupt recovery? By: Mostafa El-koumy
EMBEDDED KEYWORDS (INTERACTIVE)  Scope and life time with keywords:  Static local  Static global  Volatile  Const  Extern  register By: Mostafa El-koumy
FUNCTIONS VS MACROS  Macros in completely text replacement so it increase the code size and duplications.  Function is preferred. By: Mostafa El-koumy
MACROS VS INLINE FUNCTIONS  In Inline functions Compiler substitute the function call by function code like MACROS.  MACROS is supported by preprocessor so all the IDEs supports it.  Inline is supported by some compilers.  Inline function performs type checking but MACROs not.  Inline function could be traced but MACROs not.  Some compiler disable inline function when the its code is large.
Exercise 2 By: Mostafa El-koumy UART MODULE
Thank you for your attention! Any Questions? By: Mostafa El-koumy
CONTACT DETAILS  Mostafa El-koumy  Embedded SW Developer  mostafa.elkoumy@gmail.com

Embedded C workshop

  • 1.
  • 2.
    Introduction ? o Introduction toEmbedded C. o Embedded Software Architecture. o Memory usage. o Embedded Development Environment. o Interrupts. o Keywords. o Some Embedded Systems concepts. By: Mostafa El-koumy
  • 3.
    INTRODUCTION  Embedded Systemsis all things around you which have something called electronic brain to make some sort of artificial intelligence.  Embedded C is a prober subset of C language suitable for Embedded systems, it defines only a new concept of writing software.  Using Embedded C, we should handle everything used in the program like Memory Management, HW Registers, interrupts, …. Etc. By: Mostafa El-koumy
  • 4.
    MISRA RULES  MotorIndustry Software Reliability Association.  Collaboration between engineering consultancies which seeks to promote best practice in developing Automotive Systems and other embedded systems.  To this end MISRA publishes documents that provide accessible information for engineers and management, and holds events to permit the exchange of experiences between practitioners.  URL : www.misra.org.uk  EX: By: Mostafa El-koumy
  • 5.
  • 6.
    EMBEDDED SOFTWARE ARCHITECTURE(CON’T) By: Mostafa El-koumy
  • 7.
    CODE FLOW  Allthe code is running within infinite loop in main except:  Initialization code.  Interrupt handlers, interrupt service routines (ISR).  The other code runs normally int main (void) { intitializeModule(); sei(); while(1){ startApplication(); } return 0; } By: Mostafa El-koumy
  • 8.
    BACKGROUND/FOREGROUND TASKS (LOWCOST) By: Mostafa El-koumy
  • 9.
    SOFTWARE MODELING Function C file Module Project Cfile(s) H file(s) SW module Uart.c Uart.h Uart_irq.c Uart_cfg.h
  • 10.
    MEMORY USAGE BYLINKER SCRIPT  The HW Registers  Stack space that grow down  Local variables  Functions return address  Heap Space that grow up  Zero default initialized variables  Initialized with value by developer By: Mostafa El-koumy I/O Addresses Stack (grow down) Heap (Grow up) Un-initialized data (.BSS) Initialized data
  • 11.
    DEVELOPMENT ENVIRONMENT  IDEwhich has  Text editor.  Cross compiler produce machine language By: Mostafa El-koumy
  • 12.
  • 13.
    DEVELOPMENT ENVIRONMENT  Incircuit Debugger (ICD)  HW device connects to the microprocessor using JTAG/SWD interface to support external control of the microprocessor using debugger.  Restrictions of debugging capabilities is specified by the microprocessor. By: Mostafa El-koumy
  • 14.
    DEVELOPMENT ENVIRONMENT  Incircuit Emulator (ICE)  HW device used to debug embedded SW. it replaces the microprocessor with control over all the aspects of it and it usually emulate all the microprocessor family. By: Mostafa El-koumy
  • 15.
  • 16.
  • 17.
    INTERRUPTS  an interruptis a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code the processor is executing.  Interrupt sources  Internal peripherals.  External interrupts.  SW interrupts.  Exception thrown by processors. By: Mostafa El-koumy
  • 18.
    INTERACTIVE QUESTIONS  Maskable interrupt?  Non-Mask able interrupts?  Level triggered external interrupt?  Edge triggered external interrupt?  Interrupt nesting? By: Mostafa El-koumy
  • 19.
    INTERRUPT TIMING  Interruptlatency?  Context?  Interrupt response?  Interrupt recovery? By: Mostafa El-koumy
  • 20.
    EMBEDDED KEYWORDS (INTERACTIVE) Scope and life time with keywords:  Static local  Static global  Volatile  Const  Extern  register By: Mostafa El-koumy
  • 21.
    FUNCTIONS VS MACROS Macros in completely text replacement so it increase the code size and duplications.  Function is preferred. By: Mostafa El-koumy
  • 22.
    MACROS VS INLINEFUNCTIONS  In Inline functions Compiler substitute the function call by function code like MACROS.  MACROS is supported by preprocessor so all the IDEs supports it.  Inline is supported by some compilers.  Inline function performs type checking but MACROs not.  Inline function could be traced but MACROs not.  Some compiler disable inline function when the its code is large.
  • 23.
  • 24.
    Thank you for yourattention! Any Questions? By: Mostafa El-koumy
  • 25.
    CONTACT DETAILS  MostafaEl-koumy  Embedded SW Developer  mostafa.elkoumy@gmail.com