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


EL3250 Practical Assessment


This assessment tests your ability to write and test code for an ARM Cortex Microcontroller STM32L476.  All the tasks use ideas from lab work you have done earlier in the course.

You will use the same equipment you used to complete the module laboratory work.  You will need to access the EL3250 Blackboard Module for reference material.

There are 4 tasks which need to be completed.  You will be assessed on the code you submit, and the answers to the questions about each of the tasks.  You may consult your previous lab work and any other on-line materials to help you write the code.  The submission will be a Word document containing the answers to the questions + a zip file of the complete Keil project folder containing your code.  The answers to the questions will form the main part of the assessment, and we may look at your code if we need clarity on anything you have done.

The work you submit must be your own.  Standard University assessment rules apply.

You must begin a new project on the day called EL3250_2021.

You are required to create one ‘main’ file for each task, Task1main.c, Task2main.c  . . . etc. so that you only need to create one project file for the whole exercise.  You will note that Task 3 has two ‘subtasks’, in this case use two ‘main’ files called Task3_1.c and Task3_2.c

You will need to know how to create a zip file of your completed Keil project.

You will need to take screen dumps from Keil and incorporate them in your answers.

If you cannot complete any question, then in your answer, explain why you think you were unable to complete.  You may be awarded marks for appropriate ideas that just didn’t work out properly.

Each task is started on a new page, and includes the associated questions.


Task 1

You are required to output a signal that could flash an LED on port pin PC4 (the LED is not available).  The LED should be ON for 0.5 seconds and off for 1 second in a repeating sequence.  Accurate timing for this should be provided by the SysTick Timer.

You should use the logic analyser to check the timings by using it to plot the action of the LED.

 

Questions for Task 1

1. Explain how you configured PB4 to drive the LED by writing out the configuration code and adding comments.

(3 marks)

2. How accurate do you expect your timing to be?  On what does the accuracy of the timing depend?  Suggest a maximum error in the required 0.5s ON time.

(3 marks)

 

3. Copy a screen shot of the Keil Logic analyser display showing the action of the LED.  State whether the accuracy is as expected.

(3 marks)


Task 2

The Digital to Analog converter (DAC) on the STM32L476 is a 12-bit converter.  It is required to use this to output an adjustable voltage in the range 0V – 3.3 V, and that the voltage should be adjusted using the three switches on the Nucleo Shield.  The system is required to output a print-out of the current voltage using the ‘debug printf’ function of Keil, so that as it is changed, the current value is updated.  The output should be given to the nearest millivolt (one thousandth of a volt)

The three switches on the Nucleo Board (consult the information sheet on Blackboard) are labelled SW1, SW2 and ‘Push Sw’.

The required output voltages for the switch positions are as follows:

SW1

SW2

Output Voltage (V)

ON

ON

0.000

ON

OFF

0.500

OFF

ON

1.000

OFF

OFF

1.500

 

Whenever the Push Switch is pressed the output voltage should double in value, so the maximum output voltage from the system would be 3 V.

You may use the BSP476 configuration files you created earlier in the course, but it is not mandatory.

 

Questions for Task 2

1. What is the maximum and minimum voltage that the DAC can output, and what values should be sent to the DAC to achieve these values?

(3 marks)

2. Provide two screen shots: one of your code AND one of the output voltage printed out using debug printf for three different switch combinations (you choose, but state which ones you used).

(3 marks)

3. Use the separate ST-Link application to get a ‘Print via SWO viewer’ print-out of the voltage when ‘Push Sw’ is pressed and SW1 and SW2 are ON.  Capture a screen shot of this output.

(3 marks)


Task 3

There are 7 general purpose timers on STM32L476. These timers are capable of generating PWM signals to drive digital devices and plants. They can also capture signals coming to their input channel(s).

The table below (Tab. 3) shows a brief list of these general purpose timers and their features.

Tab. 3. Timers of STM32L476RG

Peripherals

Bit-depth

#chnnl

Typical Freq

TIM3&4

16-bit

4x

PCLK1

TIM2&5

32-bit

4x

PCLK1

TIM15

16-bit

2x

PCLK2

TIM16/17

16-bit

1x

PCLK2

 

Use Keil and the Nucleo board of STM32L476, work on TIM2 to answer the questions below:

1. Design a Keil based project, output PWM signal at PA5 with a designed duty cycle 50% running at 1Hz.  Show your code in C.

Note: PA5 is connected with an LED (LED0) on board.

(3 marks)

 

2. Design a Keil based project, output PWM signals with the following features:

 

a. The duty cycle changes from 0%, 30%, 60%, 0%, 30%, 60%, 0%, 30%, 60%, …

If a user presses a switch (SW1) on the shield of the Nucleo board, the duty cycle is updated as defined. Otherwise, the duty cycle stays as it is. Note: SW1 is connected with PA9.

 

b. The frequency of the signal is 1Hz

Show your project code in C.

(3 marks)

3. TIM2 can be used to capture a digital signal’s rising/falling edges. Discuss how to measure a periodical digital signal’s duty cycle by using TIM2. Present your pseudo-code. You might find the reference manual of STM32L476 useful for this question.

(3 marks)


Task 4

Realtime clock (RTC) is useful for calendar functions of embedded systems. Its core typically runs at a clock frequency - 1Hz.

Now use the RTC of STM32L476, together with Keil and the given Nucleo board, work on the following exercises:

1. Design a project, output a digital clock signal running at 0.5Hz via a GPIO pin (e.g., PA5). Show the code (in C).

(3 marks)

 

2. Explain why the configuration for the RTC you give above can output a signal of 0.5Hz.

(3 marks)

 

3. Is it possible for RTC to put a clock signal (clock signal after the 15-bit synchronous prescaler) to 10Hz? Can you supply an example? You might find the reference manual useful for answering this question.

(3 marks)