1. Write a program to continuously read the DIP switches connected to PORTA and
ID: 1937492 • Letter: 1
Question
1. Write a program to continuously read the DIP switches connected to PORTA and send it to PORTB.
2.Assume that eight DIP switches are connected to PORTB and eight LEDs are connected to PORTC. Assume that the switch values are normally high. Turn all of the LEDs on and wait in a loop until one of the switches becomes zero. At that time, send 0x55 to PORTC.
3.Write a C program to declare two character arrays called list1 and list2. Initialize list1 with your first and last name. Write the main code to copy list1 to list2.
4.Write a function to convert a character to uppercase (if it is lowercase) and return the character. Hint: Subtracting 0x20 from the ASCII code of a lowercase character makes it an uppercase.
5.Write a C program to convert a packed BCD at Port B to ASCII and display the bytes on PORTC and PORTD.
Explanation / Answer
1) SWPORTB EQU B'00001111' SW1 EQU 0 SW2 EQU 1 SW3 EQU 2 SW4 EQU 3 PICOUT EQU 4 ;connected to pin4 portB PICTXIn EQU 5 #define BD0 0x00 movf SWPORTB, W ; read PORTB andlw 0x0F ; Consider only the lower 4-bits RB0-RB3 xorlw BD0 ; Is it zero H1 btfsc PORTB, PICTXIn ; Test for Tx pin Low goto H1 ; Goto H1 loop bsf PORTB, PICOUT ; Set pin4 of portb high call Delay0.01041ms ; call 1ms delay H2 btfss PORTB, PICTXIn ; Test for Tx pin High goto H2 call Delay0.01041ms 2) http://www.scribd.com/doc/59733456/Embedded-Systems-Design-With-the-Atmel-AVR-Micro-Controller pagr no: 41 3)using System; using System.Collections.Generic; class Program { static void Main() { // Use collection initializer. List list1 = new List() { "carrot", "fox", "explorer" }; // Use var keyword with collection initializer. var list2 = new List() { "carrot", "fox", "explorer" }; // Use new array as parameter. string[] array = { "carrot", "fox", "explorer" }; List list3 = new List(array); // Use capacity in constructor and assign. List list4 = new List(3); list4.Add(null); // Add empty references. (BAD) list4.Add(null); list4.Add(null); list4[0] = "carrot"; // Assign those references. list4[1] = "fox"; list4[2] = "explorer"; // Use Add method for each element. List list5 = new List(); list5.Add("carrot"); list5.Add("fox"); list5.Add("explorer"); // Make sure they all have the same number of elements. Console.WriteLine(list1.Count); Console.WriteLine(list2.Count); Console.WriteLine(list3.Count); Console.WriteLine(list4.Count); Console.WriteLine(list5.Count); } } Output 3 3 3 3 3 4) #include#include void main() { clrscr(); char ch; coutch; { if((ch>=65)&&(ch=97)&&(chRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.