
Overview
In this project, I used Embedded C to create an interactive console application based on UART on an FPGA development board. The purpose was to establish serial communication between the Blackboard development board and a host computer over a UART connection, allowing users to enter a positive number through a terminal window. After determining whether the number is prime, the computer repeatedly searches downward until it finds the greatest prime number that is either equal to or less than the user's input. My knowledge of UART communication, memory-mapped I/O, serial data transmission, user input processing, and embedded system algorithm implementation has all improved as a result of this project.
Tools and Technologies Used
-
Embedded C
-
FPGA Blackboard Platform
-
UART Communication
-
Memory-Mapped I/O
-
Vitis Development Environment
-
Serial Terminal Interface
-
Prime Number Algorithms
-
Pointer-Based Hardware Access

board used!
KEY STEPS
1. Configure UART Communication

I began by setting up the UART peripheral for communication and creating the memory-mapped UART registers. This involved turning on the transmitter and receiver, selecting the communication mode, setting the baud rate to 115200 baud, and resetting the UART hardware before using it. Since every user contact will take place over the UART interface, establishing dependable serial connectivity was crucial.
2. Implement UART Data Transmission and Reception
I created routines to send and receive data via the serial connection after setting up the UART hardware. While the receiving function continuously monitored the receive FIFO buffer and retrieved incoming characters from the user, the transmission functions enabled the display of messages and prompts on the terminal. Working directly with UART status registers and serial communication protocols was made possible by this step.
3. Process User Input
I developed a function that gathers character input over the UART terminal and puts them in a buffer after the connection is established. The atoi() function is used to convert the input from a string to an integer when the user hits Enter. As a result, numerical input from the serial terminal could be received and processed by the embedded system.
4. Develop the Prime Number Algorithm
I created the algorithm to ascertain whether a number is prime after putting user input processing into practice. The function initially examines exceptional circumstances, such as even numbers and values smaller than two. Next, odd divisors up to the input value's square root are tested. The number is considered prime if no divisors can be discovered. My grasp of algorithm optimization and mathematical problem solving in embedded systems has improved as a result of this phase.
PUT ALL TOGETHER
Note: To view the complete code and run it, scroll down within the box if the code appears to be shrinking.
Results, Analysis, and Further Reading
By establishing UART connectivity between the FPGA development board and a host computer, the finished program made it possible for users to communicate with the system via a serial terminal. The software consistently took numerical input, analyzed it, and found the biggest prime number that was either equal to or less than the user's input. The system's successful operation confirmed the proper implementation of the prime number method, data transmission functionalities, input processing procedures, and UART settings.
I learned a lot about UART connection, memory-mapped hardware registers, embedded C programming, and algorithm implementation from this project. Additionally, I improved my comprehension of how FPGA peripherals allow ARM processor software to connect with external devices. All things considered, this project gave me hands-on experience with embedded software programming and low-level hardware interfaces.
For a deeper dive into the UART configuration process, memory-mapped register implementation, serial communication functions, and prime number algorithm design, the complete laboratory report provides detailed documentation of the entire project.




4. Integrate the Complete UART Prime Finder System
Lastly, I integrated the prime number method, user input processing, and UART connection features into a full application. The user is frequently prompted by the program to enter a value that is larger than or equal to two. If the value isn't prime, the program keeps reducing it until it finds the biggest prime number. After that, the user receives the result over the UART port. This step demonstrated how multiple software modules can work together to create a complete embedded system application.

UART Prime Number Finder Using Embedded C