Question

In: Computer Science

Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset()...

Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset() that works for both chips to reset a program.

Solutions

Expert Solution

given is Atmega128 and Pic24e have the reset interrupt at the program address 0x0 to reset it by using

AVR Libc Reference manual specifies the usage of watchdog timer for software reset. by include avr/wdt.h header file

could easily enable watchdog timer.

Code for fucntion reset() in C programming language

​
#include <avr/wdt.h>

#define reset()        
do                          
{                           
    wdt_enable(WDTO_15MS);  
    for(;;)                 
    {                       
    }                       
} while(0);
​

For Atmega128 and Pic24e types of AVRs watchdog is remain enabled after reseting the software,so we

need to add a function in the .init3 section( it excutes before main()) so watchdog would be disabled early then so it does not resetting the program again and again.

#include <avr/wdt.h>

//  Prototype of a Function
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));


//  Implementation of Function
void wdt_init(void)
{
    MCUSR = 0;
    wdt_disable();

    return;
}

Summary:- This code will reset the program for both the chips Atmega128 and Pic24e.


Related Solutions

Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset()...
Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset() that works for both chips to reset a program.
This is a atmega128 source to make a clock using the timer interrupt. I want to...
This is a atmega128 source to make a clock using the timer interrupt. I want to add source if i press switch (PIND==0x0FE&&PIND==0x0FD) then below program would be running . #include<io.h> int position=0,BJT[4]={0xFE,0xFD,0xFB,0xF7}; int number=0,segment[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; int msec=0, sec=0, min=0; void main() { DDRA=0xFF; PORTA=0XFF; DDRB=0xFF; PORTB=0xFF; TCCR0=0x04; TIMSK=0x01; SREG=0x80; while(1){} } interrupt[TIM0_OVF]void timer0_ovf_isr() { TCNT0=0x06; PORTA=BJT[position]; if(position==0)number=sec%10; if(position==1)number=sec/10; if(position==2)number=min%10; if(postion==3)number=min/10; PORTB=segment[number]; position++; if(position>3)position=0; msec++; if(msec==1000) { msec=0; sec++; } if(sec==60) { sec=0; min++; } if(min==60)min=0; }
How does an interrupt differ from a subroutine? When an interrupt occurs, where does program control...
How does an interrupt differ from a subroutine? When an interrupt occurs, where does program control branch to?
write a python program, please. Create a program that uses the Gettysburg Address as input and...
write a python program, please. Create a program that uses the Gettysburg Address as input and outputs a list of tuples for every two words. For example: [('Four', 'score'),('and', 'seven'), ...].
Write a program that utilizes a function called paymentCalc. In the main body of the program,...
Write a program that utilizes a function called paymentCalc. In the main body of the program, ask the user what is their principal and how many months they want the loan. If it is easier, ask the user for number of years, but don’t forget to change it to months for the calculation. Use a function to calculate their monthly mortgage payment. In the main body of the program, print out what their monthly mortgage payment will be. For simplicity,...
Write the following function and provide a program to test it (main and function in one...
Write the following function and provide a program to test it (main and function in one .py) def repeat(string, n, delim) that returns the string string repeated n times, separated by the string delim. For example repeat(“ho”, 3, “,”) returns “ho, ho, ho”. keep it simple.Python
write C++ program using functions (separate function for each bottom) Write a program to find if...
write C++ program using functions (separate function for each bottom) Write a program to find if a number is large word for two given bottom base - bottom1 and bottom2. You can predict that a number, when converted to any given base shall not exceed 10 digits. . the program should ask from user to enter a number that it should ask to enter the base ranging from 2 to 16 after that it should check if the number is...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the timer interrupt for implementation. b) Write code that uses stopwatch on the second toggle in Atmel Studio
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the delay function for implementation b) Write code that uses a stopwatch on the third toggle
Write a program to implement and analyzing the Bubble Sort. a. Write a C++ function for...
Write a program to implement and analyzing the Bubble Sort. a. Write a C++ function for Bubble Sort b. Use a dynamic array of integers in a variable size of n. c. Display the following information: 1) Total counts of comparisons 2) Total counts of shifts / moves / swaps, whichever applies d. Write a main() function to test a best, and an average cases in terms of time efficiency i. Fill out the array with random numbers for an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT