Question

In: Electrical Engineering

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.

Solutions

Expert Solution

STATUS         equ       03h                 ;Address of the STATUS register

TRISB equ       86h                 ;Address of the tristate register for port B

PORTB equ       06h                 ;Address of Port B

COUNT1        equ       08h                 ;First counter for our delay loops

COUNT2        equ       09h                 ;Second counter for our delay loops

;****Set up the port****
bsf                   STATUS,5       ;Switch to Bank 1                        

movlw              00h    ;Set the Port A pins                        

movwf              TRISB ;to output.                        

bcf                   STATUS,5       ;Switch back to Bank 0


;****Turn the LED on****
Start    movlw               01h                   ;Turn the LED on by first putting                        

   movwf               PORTB    ;it into the w register and then on the port


;****Start of the delay loop 1****
Loop1    decfsz COUNT1,1       ;Subtract 1 from 255                     

goto    Loop1              ;If COUNT is zero, carry on.                     

decfsz    COUNT2,1 ;Subtract 1 from 255                     

goto    Loop1    ;Go back to the start of our loop.

   ;This delay counts down from 255 to zero, 255 times

;****Delay finished, now turn the LED off****


   movlw              00h                     ;Turn the LED off by first putting                    

   movwf              PORTB    ;it into the w register and then on the port


;****Add another delay****
Loop2       

decfsz             COUNT1,1           ;This second loop keeps the

goto                 Loop2                   ;LED turned off long enough for                    

decfsz             COUNT2,1           ;us to see it turned off                   

goto                 Loop2                   ;

;****Now go back to the start of the program
   goto                 Start                       ;go back to Start and turn LED on again

;****End of the program****
   end    ;Needed by some compilers, and also just in case we miss the goto instruction.


Related Solutions

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.
INSTRUCTIONS: I HAVE ALREADY ANSWERED QUESTION 1 AND 2. I NEED ASSISTANCE WITH QUESTIONS 3 AND...
INSTRUCTIONS: I HAVE ALREADY ANSWERED QUESTION 1 AND 2. I NEED ASSISTANCE WITH QUESTIONS 3 AND 4. I HAVE FILLED OUT THE PERCENTAGE CHANGE FOR QUESTION 3, AND NEED HELP ON CALCULATING THE OPERATING, INVESTING, AND FINANCIAL SECTIONS. AS WELL AS, THE EQUATIONS FOR QUESTION 4. IF YOU CAN ANSWER QUESTIONS 3 & 4 I WILL AWARD CREDIT. Question 1: Common size for income statement Income Statement (Common Size) :                                                                  Consolidated Income Statement 2011 % 2010 % Revenue $19,176.1...
[jAVA] Assume the following array is defined and initialized (it will already contain numbers before your...
[jAVA] Assume the following array is defined and initialized (it will already contain numbers before your code runs): public static void main( String [ ] args ) { int [ ] numbers = . . . ; // An array of integers 1) Provide code that will print the entire contents of numbers in reverse order (from the end to the beginning) 2) Provide code that will print true if the numbers are in strictly ascending order (that is, if...
Write a program that copies the even number of bits from a into the corresponding bits...
Write a program that copies the even number of bits from a into the corresponding bits in b ,only use bit-manipulation instructions, no loop int main () { uint_32 a = 0 xaabbccdd ; uint_32 b = 0 x11223344 ; // Replace bits 0 ,2 ,4 ,... of b with bits 0 ,2 ,4 ,... from a . uint_32 result = ...; // Print out the result as a hexadecimal number }
Write a program that uses an array of doubles initialized to whatever values you wish. Write...
Write a program that uses an array of doubles initialized to whatever values you wish. Write methods to calculate and return the minimum and a method to calculate and return the maximum value in the array. You must write YOUR ORIGINAL methods for minimum and maximum. You MAY NOT use Math class methods or other library methods. Write an additional method that accepts the array as a parameter and then creates and returns a new array with all the same...
This is for C++ Assuming the value of a is already defined elsewhere, convert the following...
This is for C++ Assuming the value of a is already defined elsewhere, convert the following code snippet from using a WHILE loop to using a DO-WHILE loop. Please paste in the modified code in the text area below. int k = 1; while( k <= 8 ) { a = a * k; k++; }
question: Bits 0 and 1 are transmitted in the data transmission channel,  due to a noise, a...
question: Bits 0 and 1 are transmitted in the data transmission channel,  due to a noise, a single bit is incorrectly received by a probability of 0.3 , Playback For encoding instead of bit 0, the code word 00000 and bit 1 are transmitted as code word 11111,The receiver decodes the codeword received by selecting the most frequently occurring bit ,  for example 00000 → 0, 01010 → (a) What is the probability that the received code word is correctly decoded? (b)...
Company: Apple Instructions Write a post for the Discussion Question on this topic, addressing the questions...
Company: Apple Instructions Write a post for the Discussion Question on this topic, addressing the questions below. Unless otherwise specified, each part should be 1–2 paragraphs or several bullet points in length. Part 1: Competitive Advantages List the competitive advantages of the product, service or organization you’re focusing on: the things that make it different from competitors in positive ways. Part 2: Market Niche and Positioning Strategy Describe the market niche you want to fill, along with the positioning strategy...
Write a C program to Declare an integer array of size 10 with values initialized as...
Write a C program to Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9])...
RUBY Write a DNA class that gets initialized with a string of nucleotide characters. An instance...
RUBY Write a DNA class that gets initialized with a string of nucleotide characters. An instance of DNA responds to the to_s, length, hamming_distance, contains, positions, and frequencies messages. Where a and b are DNA instances of the same length, the message send a.hamming_distance(b) returns the Hamming distance between a and b. a.contains(b) returns true if b appears as a substring in a, and returns false otherwise. a.positions(n) returns an array of the (zero-based) positions in which the nucleotide n...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT