You are on page 1of 4

Practice questions

Question:
Write a C code for bare metal CortexM3 that will blink two LEDs on PC12 (every second) and
PC13 (every two seconds) continuously after the pushbutton is pressed (once) and released on
PB4. Don’t change the data and configuration on other pins.
Question:
Write a C code for bare metal CortexM3 that will implement a delay based traffic signal. First
the Red light will be on for 20 sec. After that we will have Red and Yellow for 2 secs and then
only green for 10 secs. After that we have blinking (frequency of 2 Hz) yellow light for 3
seconds and then it switch back to red and process continues. Red light is connected on PA5,
yellow on PA6 and green on PA7.
Question:
You have a STM32F103RB board, 4x4 keypad and 20x4 LCD. We would like to make a
calculator using them.
a) Can we only display the characters of keypad?
b) Are these components enough? Do we need anything else?
c) Can we only make a one-digit calculator or more than that?
d) Do we have to use the same digits printed on keypad or can we change their positions?
Question:
Write a C code for bare metal CortexM3 that will implement the calculator (max input value is
999) as stated in question one. The calculator should be able to perform addition, subtraction,
multiplication and division, as entered by the user. (Hint: Map A as +, B as -, C as / and D as =
on keypad.) Furthermore, if user press # after one calculation, he should be able to perform
another calculation.
The display on the LCD should be as follows
Line 1: STM32F103rb Calc.
Line 2:’value1 by user’ ‘operation to perform’ ‘value2 by user’ =
Line 3: Answer is: ‘answer’
Line 4: Press # to redo.
Question:
You are working with an analogue signal from a sensor between 0 and 1.5 volts. You have a 3
bit flash type ADC to get its corresponding digital value. Design the ADC by choosing
appropriate reference voltage for this signal and show what (and how) digital value will be
corresponding an input value of 0.7 volts.
Question:
You are working with an analogue signal from a sensor between 0 and 2.5 volts. You have a 4
bit counter type ADC to get its corresponding digital value. Design the ADC by choosing
appropriate reference voltage for this signal and show what (and how) digital value will be
corresponding an input value of 1.7 volts.
Question:
You are working with an analogue signal from a sensor between 0 and 2.5 volts. You have a 12
bit successive type ADC to get its corresponding digital value. Design the ADC by using 3.6V
reference voltage for this signal and show what (and how) digital value will be corresponding an
input value of 1.56 volts.
Question:
Write the code for question 3 using C for STM32F103rb to implement question 3. The digital
and analogue values (both) should be displayed on LCD. The input is connected at Port C pin 0.
Question:
Modify the code you created for calculator with following changes
1. Use UART to display on PC instead of LCD
2. The values can be floating, i.e it should accept and give answers in decimals.
3. Use ‘#’ for ‘.’ In the keypad
4. Once the answer is displayed, it should restart for next calculation automatically (without
waiting for ‘#’
Question:
Write a program in C to detect input of 2 potentiometers and display their values

Question:
Write a program in C to detect input of potentiometer. The program should switch on one led if
value is less than 100, two if value is between 100 and 1000, three if its between 1000 and 2500
and 4 if it is above 2500.

Question:
Write a C program to blink LED on PA5 and display port and pin number on UART at a rate of
4800 bytes per second

Question:
Write a program to control LED on PA5 by User Button and display appropriate message on
UART.

Question:
Write a C program to display string of your name on STM32F103 UART

Question:
Write a C program to detect key from keypad and display its binary value on LCD.

Question:
Write a C program to detect key from keypad and turn on key pressed number of LED’s

Question:
Write a C program to display name of student if last 2 digits of his reg. no. are entered through
keypad (Take data of 5 students)

1st line: L1F18BSEE00xxI/P Entered through Keypad


2nd line: xxxxxxxxxxxxxxStudent name should be printed on LCD
Question:
Write a code on STM32 to display value of floating type variable on LCD when user button is pressed.

Question:
Implement PWM on Timer 3 channel 4 with 500 Hz 40% duty cycle

Question:
Implement PWM with 2 kHz 80% duty cycle and PA5 toggle at same time.
Question:

Write a C code for bare metal that will perform the following functions on
STM32F103rb.
a. Enable UART communication at a buadrate of 4800 between STM
board and PC.
b. If numeric keys (0-9) are pressed on keypad, the same should be
communicated to PC. If ‘*’ is pressed, It sends whatever string is
saved in variable test and if # is pressed it sends whatever integer
value is saved in variable data.
Question:

Write a C code for bare metal that will perform the following functions on
STM32F103rb.
a. Switch on the yellow LED on PB8 for 500 millisecond and switch off
the LED for 150 millisecond continuously.
b. Control the speed of the motor by providing it with a signal of 55%
duty cycle. The motor is connected on PB11 pin.
Question:

Write a C code for bare metal that will perform the following functions on
STM32F103rb.
a. Switch on the blue LED on PB8 for 100 millisecond and switch off
the LED for 150 millisecond.
b. Control the speed of the motor by providing it with a signal of 75%
duty cycle. The motor is connected on PA2 pin.

You might also like