Question

In: Electrical Engineering

Question 1: Answer the following questions related to AVR Timer/counter: Write an AVR program that flashes...

Question 1:

Answer the following questions related to AVR Timer/counter:

  1. Write an AVR program that flashes an LED (PC0) every 6 ms using CPU clock frequency of 32 kHz and TIMER0. Use Timer/Counter0 Overflow Flag (TOV0) in your code.
  2. Write an AVR program that flashes an LED (PC0) every 2 seconds using XTAL clock frequency of 16MHz and Timer1. Use Timer/Counter1 Overflow Flag (TOV1) in your code.

Solutions

Expert Solution

1.AVR program that flashes an LED (PC0) every 6 ms using CPU clock frequency of 32 kHz and TIMER0

#include<avr/io.h> Void timer0_init() { //set up timer with no prescale TCCR0 |= (1<< CS00); //Initialization of counter TCNT0 = 0; } int main(void) { // connecting led to pin PC0 DDRC |= (1<<0); timer0_init(); while(1) { if (TCNT0 >= 191) { PORTC ^= (1<<0); //LED toggles TCNT0 = 0; } } }

2.AVR program that flashes an LED (PC0) every 2 seconds using XTAL clock frequency of 16MHz and Timer1

#include <avr/io.h> #include <avr/interrupt.h> volatile uint8_t tot_overflow; // initializing timer, interrupt and variable void timer1_init() { TCCR1B |= (1 << CS11); TCNT1 = 0; TIMSK |= (1 << TOIE1); // enable the global interrupts sei(); // initializing overflow counter variable tot_overflow = 0; } // TIMER1 overflow interrupt service routine is called whenever TCNT1 overflows ISR(TIMER1_OVF_vect) { tot_overflow++; if (tot_overflow >= 61) { PORTC ^= (1 << 0); tot_overflow = 0; } } int main(void) { DDRC |= (1 << 0); timer1_init(); while(1) { // do nothing // comparison is done in the ISR itself } }

Thank YOU


Related Solutions

1a. Write your Verilog program to implement the timer counter. HEX0 should show tenths of seconds...
1a. Write your Verilog program to implement the timer counter. HEX0 should show tenths of seconds from 0 to 9. HEX1 and HEX2 should show a count of seconds, from 00 to 59. The ones count is on HEX1 and the tens count is on HEX2. 1b. Count backwards and forwards. Add a button or switch to control counting direction. When counting forwards or backwards, your count should not stop but rollover appropriately at the correct time. When counting forward,...
Question 1: Write an AVR program to display text on a 2-line WH2002 LCD display based...
Question 1: Write an AVR program to display text on a 2-line WH2002 LCD display based on the HD44780 controller. Apply the following: The LCD instruction/data bus is connected to PORTD, and control bus is connected to PORTB (RS is connected to PB0, R/W to PB1, E to PB2). Use the #define command to name PORTD as Display_port. Use the #define command to name PORTB as Control_port. The displayed information is stored in the microcontroller Flash ROM (maximum size of...
Question 1: The following table to answer the following questions.
Question 1: The following table to answer the following questions.  a. Sketch the aggregate supply(s) and aggregate demand diagram(s). b. What is the equilibrium output and price level? c. If aggregate demand shifts right, what is long-run equilibrium output? d. If aggregate demand shifts left, what is equilibrium long-run output? e. For an economy at long-run equilibrium, would you suggest using aggregate demand to alter the level of output or to control any inflationary increases in the price level? Why?
1: Answer these questions: (a) Write a Java program to print whole numbers between 1 to...
1: Answer these questions: (a) Write a Java program to print whole numbers between 1 to 1000 which are divisible by 3, 5 and by both numbers. (b) Differentiate between instance and local variable in Java (c) In a tabular form, differentiate between instance and class variable
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
Question (1) Answer each of the following questions briefly. These questions are based on the following...
Question (1) Answer each of the following questions briefly. These questions are based on the following relational schema: Emp(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, pcttime: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) (a) (5 points) Give an example of a foreign key constraint that involves the Dept relation. What are the options for enforcing this constraint when a user attempts to delete a Dept tuple? (b) (5 points) Write the SQL statements...
Please answer these questions in as long of detail as possible. Question 1 a) Write the...
Please answer these questions in as long of detail as possible. Question 1 a) Write the expression used to calculate rate of digestion as it’s related to starch concentration and time: b) Explain what a catalytic process is and how it is different from the non-catalytic version of the process. Give an example of an enzymatic process other than amylase and describe the substrate(s)/product(s): c) Describe what the enzyme amylase does and what would happen in the absence of this...
Please answer the following questions, 1- Explain a problem/question related to your work 2- make up...
Please answer the following questions, 1- Explain a problem/question related to your work 2- make up a fictional data set with the variables that you'll need to answer your question or solve your problem; 3- Apply appropriate data analysis tools; 4- Draw conclusions regarding your question based on your results. 5- Finally, upload your work in one Excel spreadsheet.
Given the following program below answer the following questions. 1.Draw a program flow graph for the...
Given the following program below answer the following questions. 1.Draw a program flow graph for the binsearch() function 2. Find the Define and Usage node, du-paths and dc-paths for all the variables int binsearch(int x,int v[],int n) { int low,high,mid; low=0; high=n-1; while(low<high) { mid = ( low + high ) / 2; if( x < v[mid]) high = mid - 1; else if ( x > v[mid]) low = mid + 1; else return mid; } return -1; }
write a program for the msp430fr6989 Using the general purpose timer, specifically the ACLK, create a...
write a program for the msp430fr6989 Using the general purpose timer, specifically the ACLK, create a program which makes LED1 stay on for 4 seconds and off for 2 seconds and repeat indefinitely. Modify the above program to extend the timing to 20 and 10 seconds, respectively.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT