关键词 > ELEC3607

Embedded Systems – ELEC3607 Semester 1 – 2016

发布时间:2024-06-08

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Faculty of Engineering

Embedded Systems – ELEC3607

Semester 1 – 2016

Section A - Peripherals (25 marks)

A data sheet for the SAM3X Serial Peripheral Interface (SPI) peripheral is included at the end of this paper. In answering this question, you must give all constants for register addresses and values in hexadecimal.

1. (10 marks) Assuming that the chip has just been reset, explain the sequence required to initialize SPI1 in master mode. Enable the Variable Peripheral Select mode, such that you can address up to 4 peripheral devices without using a decoder. Configure the protocol mode (clock polarity and phase) for chip select 0 such that an 8-bit data is shifted on the rising edges and captured on the falling edges of the clock. Assuming a MCK of 84 MHz, set the baud rate to 4 Mbps. Do not enable any other mode or option (for example, interrupts or fault detection). The names, addresses and values for all relevant registers should be included and you should justify the values chosen for each field. Do not include any code in your answer.

2. (10 marks) In the C programming language, write a code sequence which will send 0 to 9 as 8-bit values to slave 1 (connected to NPCS1) using SPI1. Use polling, and assume that SPI1 is already configured using your answer in part 1. Do not enable any other mode or option (for example, last transfer signals or shutdown). Your answer should not use any library calls or include files, must be clearly commented and use meaningful variable names.

3. (5 marks) Explain clearly how a UART transmits data, and draw the waveform required to transmit 8-bit value 0x03 with odd parity. Annotate your waveform to show where each bit is transmitted. Label both x and y axis, assuming it is measured from a SAM3X with a baudrate of 1000 bps.

Section B - ARM Assembly Language (25 marks)

An ARM instruction set summary is provided at the end of this paper.

1. (5 marks) In a little-endian system, 32-bit value 0x12345678 is stored in memory location 0x40000000. In a table, with a “memory location” column and a “stored data” column, show what byte values are stored at each memory location.

2. (10 marks) The following is the assembly language translation of a C function.

mystery:

       mov r3, r0

       mov r0, #0

.L3:

       ldrb r2, [r3, #1]!

       cmp r2, r1

       bhi .L4

       add r0, r0, #1

       b .L3

.L4:

       bx lr

Annotate each line of the function with comments to explain what each line does. Write an equivalent C function and explain what it does.

3. (5 marks) Give a single assembly language instruction which will clear bits 4 to 7 of the r2 register.

4. (5 marks) Give a single assembly language instruction which will load the negated value of r2 into r1 only if flag V is set.

Section C - Interrupts (25 marks)

1. (10 marks) Assuming that the chip has just been reset, explain how to program the registers of SPI1, so that it is set to slave mode and an interrupt is generated after each byte of data is received. Assume all clock settings to be similar to Section A. The names, addresses and values for all relevant registers should be included and you should justify the values chosen for each field. Do not include any code in your answer.

2. (10 marks) In the C programming language, write an interrupt handler spi_irq() that is called when an SPI receive event occurs. If data has arrived in the receive data register and its value is less than 96, then set Digital Pin 4 to 1, otherwise to 0. If an OVERRUN error has occurred, then set Digital Pin 5 to 1, otherwise to 0. Your answer should not use any library calls or include files (except for digitalWrite(pin, value)), must be clearly commented and use CMSIS naming scheme for all registers and flags. You can assume that SPI and other parts of the system, such as NVIC and PIO, have been already programmed.

3. (5 marks) In the context of SPI to UART data transfer (as described in part 2), explain the purpose of using direct memory access. Give an example of a situation in which it is not advantageous over the implementation of part 2.

Section D - Hardware Design (25 marks)

1. (5 marks) Suppose we need to drive 48V DC motor using a 3.3V microcontroller. Draw a circuit which is optically isolated and makes this conversion.

2. (5 marks) Explain one advantage and one disadvantage of a Schottky diode over a traditional P-N junction diode.

3. (5 marks) Name the signals used in I2C busses. Draw an open-drain output and explain why it is used in I2C.

4. (5 marks) Draw a Pierce crystal oscillator. Name each component on your figure.

5. (5 marks) Explain what voltage sag in digital circuits is. Why a network of capacitors is required to reduce this effect instead of only one capacitor?