Sie sind auf Seite 1von 5

Embedded Systems Engineering 301Semester 1,2005

Question 1: (a) Describe the basic approach to the creation of finite state software. Under what conditions is this approach useful in embedded systems? [10 marks] (b) Interrupts are essential for most embedded system operations. Describe the various methods of dealing with processor registers when entering and leaving an interrupt service routine. [10 marks] (c) There are several reserved words in ANSI C which can be of considerable help in embedded software. Describe two and indicate where these are of particular use. [10 marks] Question 2: A 10bit Analogue to Digital Converter is to be used to measure and display the outside temperature of a car. The car is to be sold on the global market and so the expected temperature range is -40 degrees C to +50. The system designers decide to use the extreme bit codes 0x000 and 0x3FF as over and under range values. (a) Can this system show the temperature to 0.01 degree C resolution with 0.01 temperature change increments? Explain your answer. [10 marks] (b) It is decided by the designers to only show the temperature to 0.1 degree C resolution. What is the basic relationship between the A/D output code and the temperature to be displayed. [10 marks] (c) Assuming that it is preferable to shift rather than divide suggest an appropriate algorithmic process for the relationship proposed in (b). [10 maks] (d) Two slightly different approaches to the final system may be adopted. One uses hardware scaling and minimal software conversion and the other software computation as in (c). Describe them both and comment on the advantages and disadvantages of both. Indicate any changes which should be made in the over and under range values where appropriate. [10 marks]

Embedded Systems Engineering 301Semester 1,2005

Queston 3: Consider the following C code. struct word {byte high, low}; union { word w; unsigned int i; } uvalue; uvalue dutyc; byte control; dutyc.w.high = control; TOC1 = dutyc.i; a) Explain this code. [10 marks] b) Rewrite it in a different way in C, without using struct or union. [10 marks] c) How useful it is? Give one advantage and one disadvantage. [10 marks] End of Paper

Embedded Systems Engineering 301Semester 1,2005

Solutions: Que 1: (a) Finite state software follows the organization of the finite state machine but implements it in software. Generally there is a switch statement that moves from state to state and selectors within the state to define actions based on inputs. This is the two level solution. It is quite possible to combine the state/input values in one variable to reduce the system to a single level with some increase in complexity of definitions compensated by reduction in complexity of code. Example would be as per lectures i.e. keypad code determination. Of most use when directly replacing hardwired logic. (b) Either just store return address or all registers is the commonest at the 8bit level but there are variations which have an instruction to choose a subset of regiters for the stack and unstack at the end. (c) Most likely choices are: Static provides the ability to create variables for functions which do not disappear at the end of a function execution and hence result in values which may be used during successive executions. This should be used with care but can be important. It also results in faster execution as the variables are only created once. Volatile variables are ones that may change at any time and so the compiler can not make assumptions about the current value. Examples are peripheral registers and anything which can be changed by an interrupt service routine. Que 2: (a) The system must resolve 90x100 or 9000 values for a 0.01 degree resolution display. 10 bits gives 1024 values so the system is incapable of meeting the criteria. (b) With 900 values to present and 1022 binary codes available after removing the over and under values the relationship has to scale the A/D range of values (ADin -1) by 90/1021 or 0.0882 (to 3 sign fig) and offset to give the correct range by an offset of -40.0 Note the 1021 steps not 1022 values is needed. Temperature is -40.0 + (ADin -1)*0.0882 (c) This is the same as -40.0 +(ADin -1)*882/10000 To use shifts rather than divide means we need to change the denominator to a binary power 2^13 seems appropriate so the scaling term becomes: 882/10000*8192 or 723. Is this accurate enough. Check the max value of the function: ADin = 1022

Embedded Systems Engineering 301Semester 1,2005

Temp = -40.0 + (1022-1)*723/8192 = 90.1 with truncation. The result is high try 722 this gives 89.8 with truncation and 89.9 with rounding. (d) The software scaling using the full range has a worst case error of 0.1 in 900. If the range was changed in hardware to 102.1 degrees C or 0.1 degrees per binary code then the range would be -40.0 to +62.1. Overrange could be changed to a code of 902 or 0x0386. Que 3: (a) The structure provides access to upper and lower bytes of a 16 bit word The union describes two methods of access to a pair of bytes. This version is Motorola ordered. Placing the byte value for control in the most significant byte of a 16bit unsigned word and then storing it into TOC1 gives the basis for a control variable getting set for a timing function. Probably for a PWM but not explicit in the code. (b) unsigned int dutyc; byte control; dutyc = control * 256 + dutyc%256; /* plus other variants */ TOC1 = dutyc; (c) very useful and an advantage when minimising computation complexity in code so it runs faster. Disadvantage not protable because of byte ordering on different processors.

Embedded Systems Engineering 301Semester 1,2005

Das könnte Ihnen auch gefallen