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
  • C Language! Please, comment what each line of code does in the code below and answer...

    C Language! Please, comment what each line of code does in the code below and answer this question: (sentence is fine) 1. Aside from pressing ctrl-(d/z) at the beginning of a line causing the getnchar() function to return NULL, is there any way to enter less than 9 characters? Code: void exer1(void) {    char input[LEN];    char *check; getchar(); // Clearing character buffer. printf("Please enter 9 characters: "); // Prompting the user to enter // a specific input.   ...

  • should be in C language What is the output of the following segment of C code:...

    should be in C language What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...

  • Please use C programming to write a code segment as an answer. Instead of using an...

    Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please implement a code segment by using a do-while loop. What is the output of the code? #include <stdio.h> void main() {        int i = 0;        while (i < 5);        {               printf(“%d ”, ++i);        } }

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • C++ 4. What is a driver program? 43. Consider the following function and code segment. void...

    C++ 4. What is a driver program? 43. Consider the following function and code segment. void Onet int first, int& second first 17 secondfirst 1 int main) // other code int j4; int k3; One(j, k) // other code .. After the call to OneGi, k); what are the values ofj and k?

  • c# QUESTION 1 owing code segment? What is the output for the foll Stack myStack new...

    c# QUESTION 1 owing code segment? What is the output for the foll Stack myStack new Stack0: myStack.Push One"); myStack.Pushl Two"); myStack.Push( Three"); myStack Push Four" myStack.Push Five" Console.WriteLine(myStack.PopO): O One Two O Three O Four Five QUESTION 2 What must x be to print out a 'G' in the the following code fragment? char i = (char)((int)x + 3); Console.WriteLine(); O charx 65; O charx 75; char x = 'A'; O char x-D O intx 68; QUESTION 3 What...

  • help 9. Consider the following code segment: Struct some Int a: Long bi Char c Void foo (struct some s) S.a -21 s.b 1989: Int main0 Struct some thing: Foo (thing) Label the following stack diagra...

    help 9. Consider the following code segment: Struct some Int a: Long bi Char c Void foo (struct some s) S.a -21 s.b 1989: Int main0 Struct some thing: Foo (thing) Label the following stack diagram-from the perspective of function foo-each field of the struct should be clearly marked. Assume 8 byte wide words. 0x060 0x068 0x070 0x078 0x080 Ox088 Ox090 0x098 0x100 Ox108 Old base pointer Return address 9. Consider the following code segment: Struct some Int a: Long...

  • What are the first five lines printed from this code and why? public class LoopQ {...

    What are the first five lines printed from this code and why? public class LoopQ { public static void main(String[] args) { for(char c = 'A'; c < 'Z'; c++) { for(int i = 0; i < 2; i++) { System.out.println("seat "+c+i); } } } }

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • c++ In the following segment of the code, what will be the output if opening of...

    c++ In the following segment of the code, what will be the output if opening of the file is not successful? ifstream infile; try{ infile.open("test.txt"); if(!infile) throw -1; else cout << "successful" << endl; } catch(const char* msg) { cout << msg << " unsuccessful" << endl; } catch(int i) { cout << i < was returned, unsuccessful" <<endl; #8 WA w

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