Question

In: Computer Science

Q8. If the bits 0 and 2 of P1IN are set, then toggle all the bits...

Q8. If the bits 0 and 2 of P1IN are set, then toggle all the bits of P1OUT simultaneously except the bit 4, else toggle only the bit 4 of P1OUT.

Solutions

Expert Solution

Hello,

#include <msp430g2553.h>
volatile unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;

   P1DIR |= BIT0;               // P1.0 output, BIT0 is define as (0x0001) in the header file
   P1OUT &= ~BIT0;            // P1.0 output LOW, LED Off

   P1DIR |= BIT6;                // P1.6 output
   P1OUT &= ~BIT6;            // P1.6 output LOW, LED Off

   for (;;)
   {
       P1OUT ^= BIT0 + BIT6; // Toggle LED at P1.0 and P1.6
                               // Here BIT1 and BIT6 added and relevant two bits will be toggled


       for(i=0; i< 20000; i++);   // Delay between LED toggles.
   }
}

If you find this answer useful, please upvote


Related Solutions

question#1: Write instructions to toggle bits Bit0 of PORTB assuming the PORTB is already initialized as...
question#1: Write instructions to toggle bits Bit0 of PORTB assuming the PORTB is already initialized as an output port. question#2: The following unsigned integer readings are stored in data register starting from REG10 (address 10H). Data (H): 40, 45, 4A, 32, 52, 38, 3A, 44 Write a program that finds the average temperature. Simulate your program in PIC18 IDE Simulator and attach a screenshot of your simulation while the program is running.
from PIL import Image def stringToBits(string):     return str(bin(int.from_bytes(string.encode(), 'big')))[2:] def bitsToString(bits):     if bits[0:2] != '0b':         bits.
from PIL import Image def stringToBits(string):     return str(bin(int.from_bytes(string.encode(), 'big')))[2:] def bitsToString(bits):     if bits[0:2] != '0b':         bits = '0b' + bits     value = int(bits, 2)     return value.to_bytes((value.bit_length() + 7) // 8, 'big').decode() def writeMessageToRedChannel(file, message):     image = Image.open(file)     width, height = image.size     messageBits = stringToBits(message)     messageBitCounter = 0     y = 0     while y < height:         x = 0         while x < width:             r, g, b, a = image.getpixel((x, y))             print("writeMessageToRedChannel: Reading pixel %d, %d - Original values (%d, %d, %d, %d)"...
1. With mutation set to 0, migration set to 0, all genotypes with equal fitness, and...
1. With mutation set to 0, migration set to 0, all genotypes with equal fitness, and assortative mating set to 0, what would you expect to happen and why? a. allele frequencies should change dramatically, because microevolution is occurring b. new alleles will be entering the population, which will change allele frequencies c. some phenotypes are more adaptive than others, so they will increase in frequency over generations d. allele frequencies should stay about the same, because microevolution is not...
in the MSP430FR6989 what bits are set to “turn on” LCD_B1?  
in the MSP430FR6989 what bits are set to “turn on” LCD_B1?  
Let W be the set of P4 consisting if all polynomials satisfying the conditions p(-2)=0. a.)...
Let W be the set of P4 consisting if all polynomials satisfying the conditions p(-2)=0. a.) prove that W is a subspace of P4 by checking all 3 conditions in the definition of subspace. b.) Find a basis for W. Prove that your basis is actually a basis for W by showing it is both linearly independent and spans W c.) what is the dim(W)
How do you display all the formulas in an Excel spreadsheet? There is a toggle switch...
How do you display all the formulas in an Excel spreadsheet? There is a toggle switch and you start by pressing CTRL and then another character. What is the other character to allow you to display all the formulas in your spreadsheet at once?
Consider the set of integer numbers from 0 to 9, that is {0, 1, 2, 3,...
Consider the set of integer numbers from 0 to 9, that is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. Bob wishes to use these numbers to create a 7-digit password to secure his new laptop. Note that each number can appear in any position (for example, 0 can be the first number in the password). (a) Find the number of 7-digit passwords that are possible. (b) Find the number of 7-digit passwords with distinct digits. (c) Find...
(2) Let Z/nZ be the set of n elements {0, 1, 2, . . . ,...
(2) Let Z/nZ be the set of n elements {0, 1, 2, . . . , n ? 1} with addition and multiplication modulo n. (a) Which element of Z/5Z is the additive identity? Which element is the multiplicative identity? For each nonzero element of Z/5Z, write out its multiplicative inverse. (b) Prove that Z/nZ is a field if and only if n is a prime number. [Hint: first work out why it’s not a field when n isn’t prime....
find all eigenvalues and eigenvectors of the given matrix A= [1 0 0 2 1 -2...
find all eigenvalues and eigenvectors of the given matrix A= [1 0 0 2 1 -2 3 2 1]
Assume that bits is a string that only contains the characters "0" and "1". n is...
Assume that bits is a string that only contains the characters "0" and "1". n is an integer variable that is less than the length of bits. Fill in the blanks below to replace bits with a new string that consists of all of the characters of bits from index n through the end, followed by the first n characters of bits. For example, if bits was "1101010" and n was 3, the new value of bits would be "1010110"....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT