Обьясните что это такое как можно проще.
(использую tini13, и прогу AlgorithmBuilder)
Причина: Тему прилепил
Код: Выделить всё
#include <tiny24.h>
#include <delay.h>
#define red PORTB.2
#define yellow PORTB.1
#define green PORTB.0
#define left PINA.5
#define right PINA.6
// Watchdog timeout interrupt service routine
interrupt [WDT] void wdt_timeout_isr(void)
{
WDTCSR|=0x40;
// Place your code here
yellow=1;
//delay_ms(10);
//yellow=0;
}
#include <delay.h>
#define ADC_VREF_TYPE 0xC0
// ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
unsigned int adc_data;
// Read the AD conversion result
adc_data=ADCW;
// Place your code here
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Input/Output Ports initialization
// Port A initialization
// Func7=Out Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=In
// State7=0 State6=P State5=P State4=T State3=0 State2=T State1=T State0=T
PORTA=0x60;
DDRA=0x88;
// Port B initialization
// Func3=In Func2=Out Func1=Out Func0=Out
// State3=T State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0x07;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 8000,000 kHz
// Mode: Fast PWM top=FFh
// OC0A output: Disconnected
// OC0B output: Non-Inverted PWM
TCCR0A=0x23;
TCCR0B=0x01;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x64;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// External Interrupt(s) initialization
// INT0: Off
// Interrupt on any change on pins PCINT0-7: Off
// Interrupt on any change on pins PCINT8-11: Off
MCUCR=0x00;
GIMSK=0x00;
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=0x00;
// Timer/Counter 1 Interrupt(s) initialization
TIMSK1=0x00;
// Universal Serial Interface initialization
// Mode: Disabled
// Clock source: Register & Counter=no clk.
// USI Counter Overflow Interrupt: Off
USICR=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
ADCSRB=0x00;
// ADC initialization
// ADC Clock frequency: 1000,000 kHz
// ADC Voltage Reference: 1.1V, cap. on AREF
// ADC Bipolar Input Mode: Off
// ADC Auto Trigger Source: None
// Digital input buffers on ADC0: Off, ADC1: Off, ADC2: Off, ADC3: On
// ADC4: On, ADC5: On, ADC6: On, ADC7: On
DIDR0=0x07;
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x8B;
ADCSRB&=0x7F;
ADCSRB|=0x10;
// Watchdog Timer initialization
// Watchdog Timer Prescaler: OSC/8k
// Watchdog Timer interrupt: On
#pragma optsize-
#asm("wdr")
WDTCSR=0x1A;
WDTCSR=0x4A;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
};
}
Не догнал...стьюдент писал(а): WDIF-WDIE-WDP3-WDCE-WDE-WDP2-WDP1-WDP0
0______0____ 1_____0____0____0_____1____0
Код: Выделить всё
ISR(SIG_WATCHDOG_TIMEOUT)
{
PORTA ^= 0xFE;
}
int main(void)
{
DDRA = 0xFF;
WDTCSR = (1<<WDCE) | (1<<WDE);
WDTCSR = (1<<WDIE) | (1<<WDP1) | (1<<WDP2);
sei();
while(1)
{
PORTA ^= 1;
_delay_ms(500);
}
}Код: Выделить всё
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
ISR(SIG_WATCHDOG_TIMEOUT)
{
PORTB ^= 2;
}
int main(void)
{
DDRB = 3;
WDTCSR = (1<<WDCE) | (1<<WDE);
WDTCSR = (1<<WDIE) | (1<<WDP1) | (1<<WDP2);
sei();
while(1)
{
PORTB ^= 1;
_delay_ms(500);
}
}Не помогло.a_skr писал(а):попробуйте поменять Ваши строчки:
WDTCSR=0x1A;
WDTCSR=0x4A;
на следующие:
WDTCSR=0x18;
WDTCSR=0x42;