You are required to output a signal that could flash LEDs on port pins PB6 and PB7 (the LEDs are not available).
The LEDs should be ON for 0.1 seconds and off for 0.1 seconds running in ‘antiphase’, i.e. when one is on, the other is off.
The GPIO pins should be configured to run at ‘Medium Speed’
Accurate timing for this should be provided by the SysTick Timer.
Copyright By PowCoder代写 加微信 powcoder
You will use the Logic Analyser to check the timings by using it to plot the action of the LEDs. You may use additional variables to help you plot the state of the LEDs.
Questions for Task 1
1. Explain how you configured port B to drive the LEDs by writing out the configuration code and adding comments (you may copy and paste from your code).
2. The debugger allows you to check configuration of GPIOs once a program has been started and stopped using a break point. Using appropriate screen shots from the Keil debugger, explain how you were able to confirm the configuration of port pins PB 6 and 7.
Using Peripherals>System Viewer>GPIOB allows the programmer to examine the values in the configuration registers once the configuration code has been run (shown opposite).
It can be seen that:
MODER 6/7 = 0x01 (output)
OSPEEDR 6/7 = 0x01 (medium speed)
(OTYPER 6/7 = 0, which is the default)
3. Copy a screen shot of the Analyser display showing the action of both of the LEDs. State whether the timing accuracy is as expected.
To get this working, students need to create dummy variables representing the LEDs that can be displayed on the Logic Analyser. They must be global (or they just get put on the stack and cannot be seen by the analyser). The analyser should display them in ‘Bit’ mode, but other ways are OK so long as the values can be seen in opposition, and changing every 0.1 second:
4. Use the debug printf() facility to output the state (1/0 or ON/OFF) of each LED whilst the program is running. Show screenshots of this output.
To get this working, students need to configure the ITM, Trace and clock speed. Without these configurations, the program could crash – in any case, it will not produce the output below:
Please turn over for main.c code
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com