An 1.M35DZ type analog temperature sensor is connected to analog port AN0 of a P
ID: 3573084 • Letter: A
Question
An 1.M35DZ type analog temperature sensor is connected to analog port AN0 of a P1C18F452 microcontroller. The sensor provides an analog output voltage proportional to the temperature, i.e., Vo = 10mV/degree C. Write a small program that shows the steps required to read the temperature. 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 is acceptable and why? What is the actual baud rate achieved using the value selected in (1)?Explanation / Answer
6 a)Variables that you define inside functionsi.e local variables are allocated on the stack. That means that the associated memory is cleaned up (the stack is "popped") when the function exits.So local variables are preferable in C with microcontrollers with limited RAM
In RAM-constrained embedded systems lacking an MemoryManagement Unit,MMU, the memory map is divided in to a section for flash memory (code and read-only data) and a section for RAM (read-write data).
c)BaudRate=F/(64*BRG+1) for BRGh=0
So SPBRG=F/64*baudrate -1
=10*10^6/(64*9600) -1
=15.2760
for BRGH=1
SPBRG=f/16*baudrate -1
=10*10^6/16*9600 -1
=64.104
2)The one with lower error rate is considered
3)Actual baud rate for bhrg=1 is
10^7/16*64.104
=9765.625
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.