Embedded C
- Why use C?
- ‘C’ is a ‘mid-level’, with ‘high-level’ features (such as support for functions and modules) and ‘low-level’ features (such as good access to hardware via pointers)
- It is efficient
- Good, well-proven compilers are available for every embedded processor
- What is Embedded 'C'?
- Embedded C is an extension of the C language to support Embedded processors
- The aim is to provide portability and access to common performance-increasing features of processors
- The Embedded C specification for fixed-point, named address spaces, and named registers gives the programmer direct access to features in the target processor, thereby significantly improving the performance of applications
- Regular/college-level 'C' programming is different from Embedded System Programming because:
- An Embedded Micro has limited memory (ROM / RAM)
- Memory Area is assigned a set of fixed locations for different purposes. ANSI C has no proper support for accessing such locations.
- Execution Speed is very important for real-time applications created using these Micros. The Micros normally have 8 bit / 16-bit support and no floating-point execution unit is present, hence programming options are limited. Only advanced microcontrollers (PowerPC) provide support for floating-point arithmetic.
- “Interrupt” service coding is not fully supported in standard C
- Some micros do not provide stack support
- A typical embedded system consists of the following major blocks
- Start-up code
- Boot Software
- Application code – The actual software
- Initialization
- Micro peripherals
- Application
- RTOS/Scheduler
- Product Application
- Interrupts
- This is the start-up file for the NEC V850SJ2 using internal memory only. This program is using the ca850 assembly language. This start-up file will perform the following actions:
- Setup default memory setup
- Ensure all interrupt levels have been service
- Initialize system Clock Module registers
- Load base pointer registers tp, gp, sp, and ep
- Load Mask Register
- Clear RAM
- call C Program main function
- Why start-up code should decide whether to jump to boot software or application software?
- Start-up checks the application software by calculating the application checksum
- If the application is corrupted (checksum failure), the control stays in the boot
- If the application is not corrupted, the control jumps to application
- Why should the control stay in the boot, if the application checksum fails?
- If the application code is corrupted, the embedded system can hang. None of the functionality will work.
- Most of the embedded systems will have an option to re-program the application software.
- Primary Boot loader
- This is the most important part of the boot software
- The communication stack specific routines are loaded at this segment of software
- Secondary Boot loader
- The major functionality of this segment is to facilitate reprogramming of the application
- This part of the boot software has the software segments to erase and flash application
- What is reprogramming?
- Reprogramming is a process of re-flashing the application code
- To achieve reprogramming, the key software blocks required includes:
- Serial driver – software to communicate with an external programmer
- Communication Manager – Maybe a vehicle bus protocol or software to decode the data
- Flash driver – software to erase/write data into Flash
- Boot software can be:
- Programmed using specific tools (external flash programmer)
- Reprogrammed using Boot Upgrader
Comments
Post a Comment