Please solve 4 and 5 only if you know the correct answer Eig

Please solve 4 and 5 only if you know the correct answer
Eight LEDs have been connected to GPIO Port A as shown below. Suppose you have a char named x Write a code segment to output x so that bits 0 to 3 of x go to the lower four LEDs and bits 4 to 7 of x go to the four upper LEDs. Suppose that the baud rate divisor is 0x682. If the peripheral clock runs at 16 MHz, what is the actual baud rate? Show your work.

Solution

4. Number of pins to port A = 11.

Number of bit to character x = 8.

The most easiest way to reach the objective is to change 8-bit character to 11-bit character by some logical operation.

Program in C language:

#include <GIOP.h>

int main ()

{

unsigned char x; // Given 8 - bit character

unsigned int z = 0; // Take a 16-bit character and initialize at zero

int i =0; // Another 8-bit character with zero initialization

int i = i + (x & 0X01); // mask the lower bit of x and stored it into i

int z = z + (x & 0X10); // mask the upper bit of x and stored it into z

int z = z << 3; // left shift the bits by three times so that upper bit of x starts from bit 7 in z

int z = z + i; // add the lower bits of x to z to get 16 bit format of x in required sequence

PA = z; // send the value of z to port A, upper five bits of z is being ignored

return 0;

}

Ans 5.

Baud divisor = 0x682 = (1666)10

Actual baud rate = clock frequency / baud divisor

Actual baud rate = 16M / 1666 =9603.84 Hz

Please solve 4 and 5 only if you know the correct answer Eight LEDs have been connected to GPIO Port A as shown below. Suppose you have a char named x Write a c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site