Explain the meaning of the following two statements and what do they accompolish
ID: 3573051 • Letter: E
Question
Explain the meaning of the following two statements and what do they accompolish: TRISBbits.TRISB0 = 1; TRISDbits.TRISD0 = 0; An LED is connected to port pin RB0 of a PIC18F452 microcontroller. Write a program to flash the LEF such that the ON time is 5 sec and the OFF time is 3 sec. Assume you have a function with the signature void delay_ms(int n), where n is the number of milliseconds delay. Use C language, write an initialization subroutine to set up INT1 as falling edge triggered and INT2 as rising edge triggered interrupt inputs high priorities. Explain how you can find the source of the interrupt when an interrupt occurs. Write the high priority interrupt subroutine (handler) that turns on the right LED (pin 1 on PORTA) when the interrupt initialized in (a) is coming from INT1 and turns on the left LED (pin 3 on PORTA) when it comes from INT2. An analog -to-digital converter has a positive input reference voltage of 5.0V and is set up for 10-bit conversion. Calculate the resolution of the ADC in millivolts per bit. What is the output code if the input voltage is 2.0V. An LM35DZ type analog temperature sensor is connected to analog port AN0 of a PIC18F452 microcontroller. The sensor provides an analog output voltage proportional to the temperature, i.e., V_0 = 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 ease 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
**********************************************Question first-both parts covered****************************************
C)Instruction and their meaning
The TRISB register controls the direction of the PORTB pins i.e it can be input / output.
1. TRISBbits.TRISB0=1;
Setting a TRISB bit (=1) will make the corresponding PORTB pin an input.
2.TRISDbits.TRISD0=0;
Bits of the TRISD register determine the function of its pins. A logic one (1) in the TRISD register configures the appropriate port pin as input where as logic zero(0) configures it as output.
TRISD bit (=0) will make the corresponding PORTB pin an output.
***********************************************************************************************************
d) Program for LED blink
#include <htc.h>
#define _XTAL_FREQ 8000000 //its frequency is 8MHz
void main() //start the prorgram here
{
TRISB=0X00; //pin is set to output
PORTB=0X00; //provides low output
while(1)
{
PORTB=0XFF; //provides high output for each line of port B
__delay_ms(1000); //dealay of 1000
PORTB=0X00; //port B gets to 0 voltage
__delay_ms(1000); //dealay of 1000
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.