Please upvote ,comment if any query . Thanks .
Note : code compiled and tested in programmer's notepad AVR.
Question 17 : toggle PB1 and PB7
/*
if we connect LED on PB1 and PB7 it will turn on and off led at every second.
*/
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
int main(void)
{
DDRB|=(1<<DDB1)|(1<<DDB7); //set output pin PB1 and
PB7
PORTB^=((1<<PB1)|(1<<PB7)); //toggle pin PB1 and
PB7
while(1)
{
//in while loop it will toggle PB1
and PB7 pin every second
PORTB^=((1<<PB1)|(1<<PB7));
_delay_ms(1000);
}
}
Question 18 : toggle only PB0
//it will turn on and off PB0 pin connected LED at every second
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
int main(void)
{
DDRB|= (1<<DDB0); //set output pin PB0
PORTB^=(1<<PB0); //toggle the pin PB0
while(1)
{
//in while loop it will toggle PB0
pin every second
PORTB^=(1<<PB0);
_delay_ms(1000);
}
}
Question 19 : set counter value from 0-99 on PORTB
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
int main(void)
{
int i;
DDRB= 0xff; //set output complete PORTB
PORTB=0x00; //set low on PORTB
for(i=0;i<=99;i++)
{
PORTB=i; //assign value to PORTB
every 200ms
_delay_ms(200);
}
}
Program 17 :
Program 18 :
Program 19 :
17. Write a C program to toggle bits PB1 and PB7. - 18. Write a C...
19. Is the instruction "CPL Pi" a valid instruction? 20. Write a program to toggle P1.2 and P1.5 continuously without disturbing the rest of the bits. 21. Write a program to toggle P1.3, P1.7, and P2.5 continuously without disturb- ing the rest of the bits. 22. Write a program to monitor bit P1.3. When it is high, send 55H to P2. 23. Write a program to monitor the P2.7 bit. When it is low, send 55H and AAH to PO...
Write a program to toggle P1.3, P1.7, and P2.5 continuously without disturbing the rest of the bits.
Solve this: Using this method exactly but with the differences asked. Program: Read the Inputs and Turn them into Outputs, Toggle PORTC bit o. Write an assembly language program for the PIC18F4520 to read 4 most significant bits switch input on bits 7-4). For each switch that is in the "ON" or high position, compliment the inputs and output the bits to PORTB, least significant bits (PORTB bits 3-0) as outputs. Repeat the procedure every 500 msec. Simultaneously Togale bit...
1=Write a program in C to get 16-bit data from Port-D and send it to ports Port-B 2-Write instructions in C to toggle both bits RD7 and RD0 continuously 3-Write instructions in C to get the status of RB2 and put it on RB0 4-Code a simple program in C to send 3499H to Port B and Port D.
04. a) Write an 8051 C program to send values 00 through FFH to port Pl. b) Write an 8051 C program to send values -3 to +3 to port P1. c) Write an 8051 C program to toggle all bits of P1 (between 55H and AAH) with some delay d) A door sensor is connected to P1.1 and a buzzer to P1.7. Write an 8051 C program to monitor the sensor and when it opens (0') sound the buzzer...
Write a program in C that reads a string of bits( so either a one or zero) in from the user one char at a time using the function getChar, which returns a char. hint in order to convert a char to an int, subtract the character. Then store the bits into an array. start with this: #include "stdio.h" #define MAX_BITS 32 int main() { printf("Enter up to 32 bits (hit 'enter' to terminate early): "); char bit = getchar();...
Write a C program that uses the bitwise shift operators to shift the bits to the right >> or the left > m; /* This shifts m bits to the right, and the m least significant bits are lost.*/ The following statements are the same. num = num >> 3; num >>= 3; Show the operation in binary by calling the following function as defined in 3.1, void to_binary(unsigned int n); The function converts decimal to binary and outputs the...
Write a program in C language that lets a user manipulate bits individually in a 4-byte variable. The program should begin with all bits having a value of zero. The program should enter a loop where it prints out the current bit values as a single integer using the twos complement bit model. It should then prompt the user to either set a bit, clear a bit, or exit. If the user desires to set a bit or clear a...
and then print their average. Write a C program that accepts a string of text from the user and prints back the string without any of the vowels. For example, if the user entered "Hello, world", the program should print "Hll, wrld" Write a C program that accepts an integer in decimal from the user and prints the number of 1' bits in the integers binary representation. For example, if the user entered 14, the program should print 3 because...
Write an ARM assembly program that checks bit 2 and bit 18 of R0. If the two bits are similar, then R8=R5<<2 (shift R5 left by 2 bits), otherwise clear the least most significant byte of R1.