Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Explain why the use of local variables is preferable in C programs designed for

ID: 3573078 • Letter: E

Question

Explain why the use of local variables is preferable in C programs designed for microcontroller with limited RAM Explain how the use of functions leads to well-structured C programs and the benefits of this design approach. Consider the case of a microcontroller operating at 10 MHz that is required to communicate at 9600 baud with the serial port on a PC. The USART is used in asynchronous mode. Calculate the possible values of the baud rate generator register (SPBRG) for BRGH = 0 and 1, respectively. Which one of the two values above in (a) is acceptable and why? What is the actual baud rate achieved using the value selected in (1)?

Explanation / Answer

a) Local variables are stored in registers (until it runs out of CPU registers). Access to registers is very quick and efficient. the local variables takes very less memory hence if we can contain everything in single function it would become easy and speed up as we are putting load on RAM

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote