170 likes | 328 Views
UEE072HM. Embedded and Real-Time Systems. We will mainly look at embedded systems Systems which have the computer system embedded within their application area, normally using a specialised single board computer (SBC)
E N D
Embedded and Real-Time Systems • We will mainly look at embedded systems • Systems which have the computer system embedded within their application area, normally using a specialised single board computer (SBC) • There is a difference between embedded and real-time – one does not imply the other • Hard real-time vs soft real-time
Embedded Systems Development • Embedded systems require host-target development – this means • The development is done on a different machine than the target • The code must be downloaded to run • Can be running on different CPU and architecture
Embedded Systems Development • Embedded systems development requires • Mixed language programming – HLL plus assembler • Increased knowledge of tools – compiler, linker and librarians • Use of specialised tools – i.e. down loaders • Special skills to debug code
Using C for Embedded Systems #define ADDRESS 0xFFFF41 main() { char *mem_p; mem_p=(char*)ADDRESS; while !(*mem_p ) ;// do nothing } • A major requirement is for direct memory access, this is achieved using pointers. • This style of code is quite common
Using C for Embedded Systems #define ADDRESS 0xFFFF41 #define MASK 0x3 main() { volatile char *mem_p; mem_p=(char*)ADDRESS; while !(*mem_p & MASK ) ;// do nothing } • Note • Use of # define • Use of char * • Use of volatile • Casting of return value • Use of binary op &
Using C for Embedded Systems • Using C in Embedded Systems you will need to know more about • Compilation process • Linking • Storage issues
Using C for Embedded Systems • Compilation issues • Passing parameters • Naming conventions • Symbol table and map generation • Assembler output
Using C for Embedded Systems • Why link HLL and ALP? • Speed • Special instructions • Code size
Using C for Embedded Systems • Ways to link HLL & ALP - passing parameters • Parameter blocks • No recursion • Using registers • Limited numbers of registers • Using the stack • Most favoured method • Many use a combination of the above
Using C for Embedded Systems • Using the stack for parameter passing, it requires • Creation of stack frame/frame pointer • Instructions to allocate/deallocate a stack frame • In 68000 • link and unlk instructions
Using C for Embedded Systems • We need to understand • Program counter • Frame pointer • Stack pointer • Stack
Using C for Embedded Systems • On reaching the following C instruction • gets(sr) • We will get the following 68000 code • jsr _gets()
Using C for Embedded Systems • Once in gets with the following C • char * gets( chat * s) • { • int str[10]; • The following assembler will be created • _get: • link a5, #-40
Using C for Embedded Systems • With the following recursive call • char * gets( chat * s) • { • int str[10]; • gets(sr);
Using C for Embedded Systems • On the final } or return statement we would get the following 68000 • unlk a5