Question

MSP430 Misc.peripherals.

Consider the following C source code.

What does the code segment from lines 9 ~ 12 do? USCIA0 is configured in the UART mode.

Consider the following C source code. 1. char gm1[]MSP430; 2. void UARTO_putdchar (char c) l 3. while (! (IFG2 & UCAOTXIFG)) UCAOTXBUF 5. while (! (IFG2 & UCAOTXIFG)) 6. UCAOTXBUF=; 7 - 9. for (int i=0; i < 6; ¡++) { 10. ch gml [il; 11 UARTO putdchar (ch) 12. ) D. (4 points) What does the code segment from lines 9-12 do? USCIA0 is configured in the UART mode.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

line 9: a for loop ahd started with initaial condition i=o and the limit condition i=6 as the character array char gm1[]="msp430" has 6 characters.the for loop iterrates 6 times reading ewach character at a time from m all the way till 0 reading all the charaters in the string "msp430".

line 10:as the for loop is iterating at every instance accepting the for loop it copies the contents of gm1[i] into ch variable.the i th character in the character array is copied to the variable ch ,for every itiration of for loop it copies a character from the 6 characters of character array till finishes all the 6 characters of gm1[] and the for loop is terminated.

line 11:the user defines function is called and the variable ch is fetched into the fuction and the function instructions are operated on it .and the funtion is palced in the line 2.when the function UART0_putdchar(ch) is called it goes to line 2 with the data if ch and all the instructions in the fuction are done exits the fuction and resumes the main code by returning to the line 13 whioch is the end of the for loop.

line 13: at line 13 it exits the for loop and starts the for loop again if the conditions i=0 and i<6 are true and gets into the for loop and executes line 12 and on .if the for loop conditions are false then it jumps to line 14 if it is writen.

NOTE:UART0_putdchar(ch) is a fuction call of the function UART0_putdchar(char c)

Add a comment
Know the answer?
Add Answer to:
MSP430 Misc.peripherals. Consider the following C source code. What does the code segment from lines 9...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT