AVR internal watchdog experiment

Publisher:RadiantGlowLatest update time:2020-02-06 Source: eefocusKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/*

Experiment 12:


AVR internal door watch experiment.


1. Experiment of watching the door. Feed the dog periodically in the main program, and start the watchdog by pressing a button to make the program loop infinitely.


2. Internal 1 M crystal oscillator, the program adopts single-task mode and software delay.


3. To conduct this experiment, please plug in all 8 short-circuit blocks of JP1 and JP3, and the short-circuit block of JP7 (LED_EN).


4. Through this experiment, you can understand the settings of the watchdog and how to feed the watchdog.


*/


#include "iom16v.h"

#include


/*Delay function*/

void delay_ms(unsigned char i) {


unsigned char a, b;

for (a = 1; a < i; a++) {


for (b = 1; b; b++) {


;


}


}


}


void main(void) {

DDRA = 0x00;/*Direction input*/

PORTA = 0xFF;/*Turn on pull-up*/


DDRB = 0xFF;/*Direction output*/


PORTB = 0xFF;/*Level setting*/


DDRC = 0x00;


PORTC = 0xFF;


DDRD = 0x00;


PORTD = 0xFF;


PORTB = 0x00;


WDR();/*Feed the dog*/


delay_ms(250);


WDR();/*Feed the dog*/


delay_ms(250);


PORTB = 0xFF;


WDTCR |= ((1 << WDTOE) | (1 << WDE));/*Startup timing*/

WDTCR = ((1<< WDE) | (1 << WDP2) | (1 << WDP1));/*Set the cycle to 1S*/


while (1) {

delay_ms(250);


WDR();/*Feed the dog*/


PORTB ^= (1 << 0);/*PB0 level inversion*/


while(PINA != 0xFF);/*Detect key press*/


}


}


Keywords:AVR Reference address:AVR internal watchdog experiment

Previous article:Building your own AVR RTOS (Part 7: Preemptive Kernel)
Next article:Building your own AVR RTOS (Part 6: Scheduling)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号