0% found this document useful (0 votes)
5 views7 pages

REPORT

The document outlines a training week focused on Microcontroller Units (MCUs), detailing various tasks such as controlling LEDs, implementing interrupt routines, and establishing serial communication. Key objectives include mastering the use of IO ports, timers, and external interrupts to enhance embedded system functionality. The training culminates in a practical understanding of MCU applications, enabling participants to pursue more complex projects.

Uploaded by

El hadji Diop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

REPORT

The document outlines a training week focused on Microcontroller Units (MCUs), detailing various tasks such as controlling LEDs, implementing interrupt routines, and establishing serial communication. Key objectives include mastering the use of IO ports, timers, and external interrupts to enhance embedded system functionality. The training culminates in a practical understanding of MCU applications, enabling participants to pursue more complex projects.

Uploaded by

El hadji Diop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

MCU REPORT

ELHADJI DIOP
李哈杰

Gu Song
INTRODUCTION:
Microcontroller Units, commonly known as MCU, are compact integrated circuits that function
as a miniaturized computer system on a single chip. These small yet powerful devices are designed
to execute specific tasks and control various electronic systems. They consist of a processor core,
memory, and input/output (IO) peripherals, making them highly suitable for embedded
applications.
The primary objective of this training week is to gain proficiency in utilizing different features of
an MCU to accomplish specific goals. These goals include:

1. Controlling LEDs using IO Ports: Understanding and utilizing IO ports to manipulate LEDs, a
fundamental task in embedded systems.

2. Arranging Tasks with Interrupt Routines: Learning to implement interrupt routines, enabling
efficient task arrangement and responsiveness to external events.

3. Synchronizing Multi-tasks with Timers: Utilizing timers to create synchronized execution of


multiple tasks, ensuring optimized performance.

4. Capturing External Interrupts: Mastering the capability to capture and respond to external
interrupts, expanding the MCU's responsiveness to real-world events.

5. Serial Communication with Other Systems: Establishing communication with external systems
using serial communication, a vital skill for data exchange between different devices.

By the end of this training, a solid foundation in these essential MCU functionalities will be
established, empowering the achievement of more complex and innovative embedded projects.

Our board(DK107Sv2.2):
During our training week we will use the Dake DK107S board v2.2, which is a very special board.
Based on its datasheet we can see that several parts of the board are connected to the P0 port of our
IAP15F2K61S2 chip and therefore to use certain part of the board it will be necessary to mention the
address of the part concerned.

CHIP IAP15F2K61S2

MCU TRAINING WEEK


2
BOARD DAKE DK107S

Controlling of LEDs:
This first task is divided into two subtasks: controlling simple LED and displaying digital
number.
Controlling simple LED:
In this subtask, we have to make L1 switch on for about 2 seconds. Then switch off L1 and
switch on L2 for about 2 seconds, and so on. (from L1 to L8).
For this we begin by defining necessary variables and including the required header files. The
`delay()` function is defined to introduce a time delay in the program.

In the `main()` function, the variable `temp` is initialized with the value `0x7F`,
representing a binary pattern to control the LEDs connected to Port 0 (P0). The value of `temp`
is then assigned to P0, lighting up the corresponding LEDs. A delay of 1000 milliseconds is
introduced using the `delay()` function.

Inside the infinite `while` loop, the code iterates through a `for` loop eight times, each time
shifting the bits in `temp` one position to the left using the `_crol_` function from the
`intrins.h` library. The updated value of `temp` is then assigned to P0, displaying the new
LED pattern. Additionally, P2 is momentarily set to 0x80 and then set to 0x00, which related
to choose the Output Y4 for control our LED. A longer delay of 20000 milliseconds is
introduced before the next iteration of the loop.

Overall, this code achieves a simple LED animation effect by shifting the lit LED pattern to the
left in a continuous loop.

Display digital number:


The task consist to Display the digital number “0” on all digital numerical leds for about 2
seconds. Then display number “1” for another 2 seconds, and so on. (from number “0” to
number “9”).
For this, we define an array `leddata` containing the binary codes to represent digits 0 to 9 on
a seven-segment display.

In the `main()` function, an infinite loop is established. Inside the loop, another loop iterates
from 0 to 9. During each iteration, the value of `i` is used as an index to select the appropriate
binary code from `leddata[]`. The selected code is then sent to Port 0 (P0), which is connected
MCU TRAINING WEEK
3
to the seven-segment display.

Before and after displaying a digit, P2 is briefly set to certain values (0xE0 and 0xC0), which
related to controlling other of the display of the digital numerical leds.

Overall, the code continuously cycles through digits 0 to 9, displaying them on the seven-
segment display with a delay of 20000 milliseconds between each digit.

Timer and Interrupt


Controlling simple LED
Here we have to make L1 switch on for about 2 seconds. Then switch off L1 and switch on L2 for
about 2 seconds, and so on (from L1 to L8, and repeat). Implement it by timer interrupt.
Our program initializes Timer 0 in 16-bit mode and sets up an interrupt service routine (ISR)
for Timer 0. When the timer interrupt occurs, the ISR sets a `timerFlag`. The main function
continuously checks for this flag, and if it is set, it displays digits 1 to 8 on the seven-segment
display with a short delay between each digit. The timer ISR ensures a regular and accurate
timing for the display updates, achieving a smooth and automated display sequence.
This program is the same as our program of the first subtask by replacing the delay function by
the Timer-Interrupt.
Display digital number:
As the second subtask, we have to display the digital number “0” on all digital numerical leds for
about 2 seconds. Then display number “1” for another 2 seconds, and so on (from number “0” to
number “9” and repeat) and implement it by timer interrupt.
As the previous task, we take our second subtask of the task 1’s program and implement there the
timer interrupt.

Controlling simple LED and Display digital number:


For this task we have to make all leds (from L1 to L8) switch on for 1 second, then switch off for 1
second, and repeat. Implement it by timer interrupt.
Here, We initializes Timer 0 in 16-bit mode and sets up an interrupt service routine (ISR) for
Timer 0. The ISR sets a `timerFlag` when the timer interrupt occurs.

In the main function, there is an infinite loop that continuously checks for the `timerFlag`.
When the flag is set, the program enters a loop to display digits 1 to 8 on the seven-segment
display with a short delay between each digit. The`timerFlag` function provides an approximate
2-second delay.

After displaying a digit, the program turns on all the LEDs by setting P0 to 0x00, then sets P2 to
0x80 and 0x00. Finally, it sets P0 to 0xFF to turn off all the LEDs, again followed by the P2
setting. This sequence is repeated for each digit, and the timer flag is reset after displaying all the
digits.
MCU TRAINING WEEK
4
Overall, the code achieves a sequential display of digits on the seven-segment LED display using
a timer interrupt for accurate timing and control.
Make my own kind
For this task, I chose to turn on the LEDs whose position is odd (1,3,5,7) and turn off the others and
do this in turn. For this work, we change the program of the previous subtask and replace the the
values of P0, 0x00 by 0xAA and 0xFF by 0x55.

Keyboard
For this task, we have to execute one of the last four different subtasks according to the button
pressed by the executor but we have encountered some problems in the execution of this task.
This is how the task has been replaced by a simpler task to know if the first is to press all the LEDs
lights up, if it is the button 2 all the LEDs goes out, the three the first four only lights up and for the
fourth button only the last four LEDs light up.
For this, we build a KeyScan() function who’ll check which button is pressed
The `KeyScan()` function continuously scans the keypad by sequentially setting each row to 0 and
checking if any key is pressed. If a key is detected, it determines its position using the column pins.
The corresponding `KeyValue` is updated accordingly to represent the pressed key.

In the `main()` function, the program enters an infinite loop where it continuously calls
`KeyScan()` to detect any key press. Depending on the value of `KeyValue`, the program performs
different actions:

- If KeyValue is 0, it turns all LEDs (P0) on.

- If KeyValue is 4, it turns all LEDs off.

MCU TRAINING WEEK


5
- If KeyValue is 8, it turns on the top 4 LEDs (P0[7:4]).

- If KeyValue is 12, it turns on the bottom 4 LEDs (P0[3:0]).

Serial Communication
For this task, we had to write a code that allows communication between our board and our machine
but unfortunately we could not finish this task. Nevertheless, we were able to complete part of this
task thanks to the help of a SUMEN classmate.
Firstly We define two functions which are The `SendData()` and `SendString()` functions,
whose send data and strings respectively via UART. The `UartInit()` function initializes UART
communication with a specific baud rate.

In the `main()` function, "OK" and the hexadecimal value 0x4F are sent over UART. The code
then enters an infinite loop, continuously scanning the keypad. If a specific key (determined by
`KeyValue`) is pressed, a response is sent over UART, and certain actions are taken, like turning
on or off LEDs connected to P0 and P2.

Additionally, the code implements an ISR (Interrupt Service Routine) for UART communication,
handling both receiving (`RI` flag) and transmitting (`TI` flag) data.
MCU TRAINING WEEK
6
CONCLUSION
Throughout the MCU training week, I gained valuable insights and practical experience in working
with microcontroller units. I successfully achieved my goals, which included using IO ports to
control LEDs, implementing interrupt routines for task arrangement, utilizing timers for task
synchronization, capturing external interrupts, and establishing serial communication with other
systems. This hands-on experience has deepened my understanding of microcontroller functionality
and their applications in embedded systems. I am now well-equipped to undertake more complex
and innovative projects, leveraging the full potential of microcontroller units.

MCU TRAINING WEEK


7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy