Embedded Systems paper



Embedded Systems paper 2003-2004

Answer All questions in Section A, plus 2 questions from Section B.

Section A. Answer all questions 60 marks total.

The numbers in the following description refer to diagram 1, which is a representation of a data transfer sessions between two machines.

A character orientated serial communication protocol allows the transfer of data packets. In order to transmit data packets the stations must agree to connect (1). The client can then transmit messages to the server. The messages can start with an optional header (2) and is then followed by data packets each terminated by an ETB character (3). The final packet must be terminated by an ETX character (7). Each packet must be either acknowledged (ACK) (4) or negatively acknowledged (NACK) (5).The NACKed data must be retransmitted (6). All packets out of sequence or with faulty checksums must be negatively acknowledged.

Client Server

ENQ-SYN-SYN-> 1

2

3

6

............

BCC-ETX-data3-STX-SYN-SYN-> 7

BCC-ETB-data1-STX-header2-SOH-SYN-SYN->

6 states starts to become a

problem. Example of coding style. Using look up tables, pointers to

functions. Use of dispatch loop. Easy to code STT into large C

structure. Use of information strings for debugging. Exampleof coding

style.

1d. Problem of timeouts. Really requries some form of ISR based on a

timer. Each state sets the timer going on entry and resets on exit.

Would also need some counter for bad packets - could be a floating value to

vary dependant upon the loading/stress of the system.

1e. Use of simulation to test and debug design first off. Modular

code - try to locate likely system/hardware dependencies - ie timer

code, serial port handling. Unit testing of each module.

Difficulties of isolating errors. Use of loopback modes - local and

remote on UART. Use of serial line monitors. Difficulties of debugging

interrupt code.

1f.General system requires - ram rom etc. Serial port requirement-

only 1 on the board so probelms there! Timer chips - 2 is useful as

one can be for OS other for application. Useful digital io - ie

diagnositic leds, keypads, lcds could be useful.

Section B

1B – i Use of simulation and unit testing very important. Requires careful segregation of hardware specific code. Tools need to produce stand alone code. Need to be targeted at hardware – and all family variants. Need to be able to see assembler output – go documentation of ALP HLL interface. More knowledge on the hardware and how it is initialised. Debugging is much more difficult. There is a download phase.

ii Compiler, assembler output, cross assembler. Ability to turn off optimisation. Relocatable code. Linker – ability to place segments in specified locations, creation of map file, linker control languages. Easy of loading different libraries esp. startup libs.Static and dynamic linking. Gas ability to inline assemble, standard assembler, easy of linking alp & hll. Variety of processor families. Objcopy – to produce various output format – ie srecord intel hex, as well as coff elf et al. Production of libraries – ability to easily maintain libs, extraction. Make ability to control complex builds, use of compiler flags, difficult command lines, ability to create various version – ie production and debug. Gdb – standard features – single step, break points, trace, register/memory dumping, disassembly, remote debugging a la gbd. Target – ability to reconfigure for various boards/targets, ability to download/upload binaries.

B2Details on link and ulnk commands

_get:

link a5,#-46 a5 frame pointer, 46 bytes

storage

unlk a5

move.l 8(a5),d0 get hold of parameter n

move.l 12(a5),a0 get hold of parameter s2

move.l 16(a5),a1 get hold of parameter s1

3B. C use of pointers, pointer arithmetic, bitwise operators, storage classes such as volatile for rt applications, can generate small code, often translate well into assembler language, easy to embed and link assembler. Problems with portability, no interrupt support, can be difficult to read, sometime as difficult as assembler.

4B i Discuss the various type of registers, mode, data and status. Go through the various settings, baud rates, bits per char etc

ii normally disable rx & tx, set up mode registers, wait for settle time, check status registers for data, space or errors, send or receive data.

iii

/* messages */

#define PAPER_OUT -1

#define DE_SELECT -2

#define YES 0

#define NO -1

#define OK 0

#define void int

/* address, offsets and setting for M68681 DUART */

#define DUART 0XFFFF81 /*base address*/

#define ACR 8 /*aux control reg */

#define CRA 4 /*command reg A */

#define MRA 0 /*mode reg A */

#define CSRA 2 /*clock select A */

#define SRA 2 /*status reg A */

#define RBA 6 /*rx reg A*/

#define TBA 6 /*tx reg A */

#define RXRDY 1 /*rx ready bit */

#define TXRDY 4 /*tx ready bit */

/* Settings for the Motorola M68230 Parallel Interface Timer

These only deal with mode 0.0 , and for ports B and C

No details about the timer.

*/

/* PI/T offsets and adresses */

#define PIT 0Xffff41 /*address of PI/T */

#define BCR 0Xe /*offset for port B cntrl Reg*/

#define BDDR 6 /*offset for B data direction*/

#define BDR 0X12 /*offset port B data reg */

#define CDR 0X18 /*offset port C data reg */

#include "io.h"

/* set up bowman 68681 duart serial port A only */

int TFLAG;

void dinit()

{

volatile char *p;

int i;

p = (char *)DUART;

*(p+ACR) = 128; /* set baud rate */

*(p+CRA) = 16; /*reset rx */

*(p+MRA) = 19; /*no modem,prty 8 bits */

*(p+MRA) = 7; /*no echo no modem cntrl, 1 sb */

*(p+CRA) = 5; /*enable rx & tx */

*(p+CSRA)= 187; /*rx & tx at 9600 */

p = ( char *) PIT; /* set to base address of PI/T */

*(p + BCR ) = MODE0; /* mode 0.0 */

*(p + BDDR ) = OUT;

for(i=0; i != 1000;i++)

;/*delay*/

}

/* set up 68230 PIT for print out on port B */

void pinit()

{

char *p;

p = ( char *) PIT; /* set to base address of PI/T */

*(p + BCR ) = MODE0; /* mode 0.0 */

*(p + BDDR ) = OUT;

}

/* get char from serial port A returns character */

char get()

{

volatile char *p;

p = (char *)DUART;

while ( !( *(p+SRA) & RXRDY ))

; /* do nothing */

return *(p+RBA);

}

/* put character c to serial port A */

char put(c)

char c;

{

volatile char *p;

p = (char *)DUART;

while ( !( *(p+SRA) & TXRDY ))

;/* do nothing */

*(p+TBA) = c;

}

/* put string to serial port A using put routine */

puts(p)

char *p;

{

while( *p )

put(*p++);

put('\n');

}

-----------------------

SYN

S3

S1

S0

GOODBCC

STX|SOH

! ETX|ETB

ETX

!SYN| STX !SOH

S2

SYN

BADBCC

ETB

S4

S5

GOODBCC

BADBCC

S6

SYN

STX

SYN

! SYN|STX

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download