Serial Communication The following diagram shows an embedded
Serial Communication
The following diagram shows an embedded system that samples an Analog signal every 100 ms.
The system provides a serial communication interface that allows sending every sample in volts (V) to a remote terminal, the terminal can send commands via the serial interface, the following list shows the commands:
Command
Value
Description
START
0x01
Start Analog signal sampling
STOP
0x02
Stop Analog signal sampling
RESET
0x03
Reset Sensor via GPIO
The sensor’s analog output range is 3V.
The serial communication to the remote terminal is asynchronous: 115200 bps baudrate, 8-bits, 1 stop bit, no parity.
The sensor reset GPIO is an active low pulse (High to Low transition), for 250 ms. If the sensor reads such a pulse the internal hardware will reset (Analog voltage output will be 0V), the sensor will operate normal as long as its RESET input is pulled high.
Write the C code of the main() function and main loop that will implement the ADC peripheral in single ended mode and sampling at 100 ms. Show your selection of the ADC channel, and TIMER. You cannot use the same channel as in previous projects, you can reference the functions and source code from the driver of those projects.
Show the C code that will implement a decoding routine of the commands sent by the remote terminal, these commands will be sent via the serial UART port at any time. Show how using the UART driver in previous projects, the commands will be received and then decoded.
Show the C code that will send the periodic ADC converted value in volts from the MCU to the remote terminal via the UART port, the voltage will be a 4-byte binary value that corresponds to the fixed point notation of the voltage read by the ADC. (You can use the UART driver functions from previous projects, you do not need to include the full source codes of these project libraries as part of your answers)
Show the C code that will generate the reset pulse when the RESET command is received, select a GPIO on the MCU, use the emlib peripheral libraries to configure the mode and state of the GPIO pin. You can use the SysTick timer for timing reference (only for this part).
1. Serial Communication
The following diagram shows an embedded system that samples an Analog signal every 100 ms.
The system provides a serial communication interface that allows sending every sample in volts (V) to a remote terminal, the terminal can send commands via the serial interface, the following list shows the commands:
Command
Value
Description
START
0x01
Start Analog signal sampling
STOP
0x02
Stop Analog signal sampling
RESET
0x03
Reset Sensor via GPIO
The sensor’s analog output range is 3V.
The serial communication to the remote terminal is asynchronous: 115200 bps baudrate, 8-bits, 1 stop bit, no parity.
The sensor reset GPIO is an active low pulse (High to Low transition), for 250 ms. If the sensor reads such a pulse the internal hardware will reset (Analog voltage output will be 0V), the sensor will operate normal as long as its RESET input is pulled high.
Write the C code of the main() function and main loop that will implement the ADC peripheral in single ended mode and sampling at 100 ms. Show your selection of the ADC channel, and TIMER. You cannot use the same channel as in previous projects, you can reference the functions and source code from the driver of those projects.
Show the C code that will implement a decoding routine of the commands sent by the remote terminal, these commands will be sent via the serial UART port at any time. Show how using the UART driver in previous projects, the commands will be received and then decoded.
Show the C code that will send the periodic ADC converted value in volts from the MCU to the remote terminal via the UART port, the voltage will be a 4-byte binary value that corresponds to the fixed point notation of the voltage read by the ADC. (You can use the UART driver functions from previous projects, you do not need to include the full source codes of these project libraries as part of your answers)
Show the C code that will generate the reset pulse when the RESET command is received, select a GPIO on the MCU, use the emlib peripheral libraries to configure the mode and state of the GPIO pin. You can use the SysTick timer for timing reference (only for this part).
| Command | Value | Description |
| START | 0x01 | Start Analog signal sampling |
| STOP | 0x02 | Stop Analog signal sampling |
| RESET | 0x03 | Reset Sensor via GPIO |
Solution
#include
