XTAL = 11.0592 MHz ; the counter counts up for each 1.085 us.So,in order to make a square wave of 0.5 Khz i.e 2 ms flipping period.
We need 2 ms/1.085 us = 1843 clocks.To acheive this many clocks; we need to load values into TL and TH :-
65536 - 1843 = F8CDH .So, TH = F8 and TL = CD
Program :-
#include<reg51.h>
sbit mybit = P1^5;
void delay(void);
void main(void){
while(1){
mybit=~mybit;
delay();
}
}
void delay(void){
TMOD = 01;
TL0 = 205;
TH0 = 248;
TR0 = 1;
while(!TF0);
TR0=0;
TF0=0;
}
8. Program Timer O in C to generate a square wave of 0.5 KHz. Assume that...
Write an assembly program using PIC18F4580 to generate a square wave of 2 kHz on pin RB.3, where XTAL=10 MHz
Answer the question below: Determine a prescalar, OCR0A value, and ISR for an 8-bit timer to generate a 400Hz square wave for 3 seconds on PD1. Recall the Arduino runs at 16 MHz and valid prescalars are: 1, 8, 64, 256, 1024(choose the smallest prescalar that works).
Write an AVR assembly code that generates a periodic square wave with 4 kHz frequency with 50% duty cycle on the OC0 pin using the Timer/Counter0 CTC mode. Assume a system clock frequency of 16 MHz. Use the follow skeleton code: ; AVR Assembly code - CTC mode with 4 kHz and 50% duty cycle .INCLUDE "m128def.inc" .DEF mpr = R16 ; General purpose register .ORG $0000 ; Reset and Power On interrupt RJMP INITIALIZE ; Jump to initialization .ORG...
Q1) ผAP to initialize 8254 for producing a square wave of 1 KHz from an input frequency of 1.625 MHz using Counter-0 Q2) WAP to initialize counter-1 of 8254 for working like a mono-stable multi-vibrator for a c unt f 1299H.
Problem 2: Portion of C code for setting up delays using SysTick Assume that SysTick Initialization has been performed correctly. Study the function below (it was used in Labl) and answer the questions that follow void SysTick_delay (void) NVIC ST RELOAD R-0x3E7F: I/ Load value for 1 ms delay NVIC ST CURRENT R = 0x0; // Clear current and start timer while((NVIC-ST-CTRL-R Ox000 10000) 0)(); // Wait until COUNT flag is & set The crystal Oscillator on the general purpose...
in c
Q3) Write a program to generate three random numbers between 1 and 9 and display them. The user has to enter their sum as soon as possible. These two steps will be repeated continuously. An alarm will be triggered every 5 seconds to display the numb answers so far. If the user did not give a correct answer in 10 seconds, the timer will jump to the main to give an error message "Too slow response!" and terminate...
Question 8 Predict the output of the following C program: 5 #include <stdio.h> void binaryCode(int n) printf("1"); if(n=2) return; binaryCode(n-1); int i = 0; for(; i<n;i++) printf("O"); binaryCode(n-2); } void main() { binaryCode(3); 12pt v Paragraph Β Ι Ο Avor T²v ...
For C++ /* rewrite the following program to generate pairs of random number until the sum of the digits of one random number equals the sum of the digits of the other random number. use only while loops in your solution. use only loop conditions to end the loop or escape the body of the loop. for example, 23( 5) 71( 8) 92(11) 6( 6) 13( 4) 99(18) 12( 3) 47(11) 63( 9) 18( 9) */ #include <cmath> #include <ctime>...
Write a Python program that generate randomly a magic square of 3 x 3 elements. For example: 4 3 8 9 5 1 2 7 6 = Matrix1 Matrix 1 above is an example of magic square. The rows total, the columns total, and the diagonal totals are all 15. Your program should randomly generate a 3x3 matrix. Check if it is a magic square. If it is a magic square, then print some information and quit. If the...
OPERATING SYSTWM
Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...