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 #define adc_port P2 //ADC Port #define rd P1_0 //Read signal P1.0 #define wr P1_1 //Write signal P1.1 #define cs P1_2 //Chip Select P1.2 #define intr P1_3 //INTR signal P1.3 void conv(); //Start of conversion function void read(); //Read ADC function unsigned char adc_val; void main() { while (1) { //Forever loop conv(); //Start conversion read(); //Read ADC P3 = adc_val; //Send the read value to P3 } } void conv() { cs = 0; //Make CS low wr = 0; //Make WR low wr = 1; //Make WR high cs = 1; //Make CS high while (intr); //Wait for INTR to go low } void read() { cs = 0; //Make CS low rd = 0; //Make RD low adc_val = adc_port; //Read ADC port rd = 1; //Make RD high cs = 1; //Make CS high }
Serial Communication The following diagram shows an embedded system that samples an Analog signal every 100 ms. The system provides a serial communication inter
Serial Communication The following diagram shows an embedded system that samples an Analog signal every 100 ms. The system provides a serial communication inter

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site