Question

How many bits are shifted out if the value in USICNT is 7 (SPI communication,USI in MSP43012013)? 7. [10] Ans: 8. Following code section is used whenever we want to send something out of UART. Ca you please write in a sentence the significance of while loop [10] while(!(IFG2 & UCAOTXIFG)): Ans: 9. Suppose you have a character array ch as follows: char chi]- I am a good person; Write a section of a code (perhaps a loop) so that all the characters in the array above is sent through UART. Consider all the configurations for setting up UART communication (baud rate, pin selection etc) is already in place. 120]
0 0
Add a comment Improve this question Transcribed image text
Answer #1

7. Data is changed on the first SCLK edge and captured on the following edge.  Send data 8 byte

8.

The below function can be used to transmit data through the UART module:

//**Function to send one byte of date to UART**//
void UART_send_char(char bt)  
{
    while(!TXIF);  // hold the program till TX buffer is free
    TXREG = bt; //Load the transmitter buffer with the received value
}
//_____________End of function________________//

Once the module is initialized whatever value is loaded into the register TXREG will be transmitted through UART, but transmission might overlap. Hence we should always check for the Transmission Interrupt flag TXIF. Only if this bit is low we can proceed with the next bit for transmission else we should wait for this flag to get low.

However, above function can be used only to send only one byte of data, to send a complete a stringthe below function should be used

//**Function to convert string to byte**//
void UART_send_string(char* st_pt)
{
    while(*st_pt) //if there is a char
        UART_send_char(*st_pt++); //process it as a byte data
}
//___________End of function______________//

This function might be a bit tricky to understand since it has pointers, but trust me pointers are wonderful and they make programming more easy and this is one good example of the same.

As you can notice we have again called the UART_send_char() but now inside the while loop. We have split the string into individual characters, each time this function is called, one char will be sent to the TXREG and it will get transmitted.

Add a comment
Know the answer?
Add Answer to:
How many bits are shifted out if the value in USICNT is 7 (SPI communication,USI in...
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
  • This is for C++ Write a program that reads in a sequence of characters entered by...

    This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • This looks long but it is easy just having some trouble please help out thank you....

    This looks long but it is easy just having some trouble please help out thank you. Find and fix all syntax and semantic errors which prevent the program from compiling. Find and fix all logical errors which cause the program to crash and/or produce unexpected results. In addition to making sure the code compiles, we have one final method which we need to complete. There is a method in the code, printAll, which is responsible for printing out the entirety...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

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