Код: Выделить всё
UCSR0C=(3<<UCSZ00); Компилируется и работает нормально.
Код: Выделить всё
UCSR0C=(3<<UCSZ00); Код: Выделить всё
UCSR0C=(3<<UCSZ00); Код: Выделить всё
UCSR0C=_BV(UСSZ00) | _BV(UCSZ01);Код: Выделить всё
UCSR0C=(1<<UСSZ00) | (1<<UCSZ01);Код: Выделить всё
USART_Init:
; Set baud rate
out UBRRnH, r17
out UBRRnL, r16
; Enable receiver and transmitter
ldi r16, (1<<RXENn)|(1<<TXENn)
out UCSRnB,r16
; Set frame format: 8data, 2stop bit
ldi r16, (1<<USBSn)|(3<<UCSZn0)
out UCSRnC,r16
retКод: Выделить всё
Enable receiver and transmitter */
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
/* Set frame format: 8data, 2stop bit */
UCSR0C = (1<<USBS0)|(3<<UCSZ00);Код: Выделить всё
USICR = 0<<USISIE | 0<<USIOIE | 1<<USIWM1 | 0<<USIWM0 | 1<<USICS1 | 0<<USICS0 | 1<<USICLK | 0<<USITC;Код: Выделить всё
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1200,000 kHz
#define _CS1 1
// Mode: CTC top=OCR1A
#define _WGM1 4
// OC1A output: Disconnected
#define _COM1A 0
// OC1B output: Disconnected
#define _COM1B 0
// Noise Canceler: Off
#define _ICNC1 0
// Input Capture on Falling Edge
#define _ICES1 0
// Timer1 Overflow Interrupt: Off
#define _TOIE1 0
// Input Capture Interrupt: Off
#define _ICIE1 0
// Compare A Match Interrupt: Off
#define _OCIE1A 0
// Compare B Match Interrupt: Off
#define _OCIE1B 0
// Timer/Counter 1 initialization
TCCR1A=(_COM1A<<COM1A0) | (_COM1B<<COM1B0) | ((_WGM1&3)<<WGM10);
TCCR1B=(_ICNC1<<ICNC1) | (_ICES1<<ICES1) | ((_WGM1>>2)<<WGM12) | (_CS1<<CS10);
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=(_TOIE1<<TOIE1) | (_OCIE1A<<OCIE1A) | (_OCIE1B<<OCIE1B) | (_ICIE1<<ICIE1) | (_OCIE0B<<OCIE0B) | (_TOIE0<<TOIE0) | (_OCIE0A<<OCIE0A);
Код: Выделить всё
// Timer/Counter 1 initialization
#if defined(_COM1A) || defined(_COM1B) || defined(_WGM1)
TCCR1A=0
#ifdef _COM1A
| (_COM1A<<COM1A0)
#endif
#ifdef _COM1B
| (_COM1B<<COM1B0)
#endif
#ifdef _WGM1
| ((_WGM1&0b11)<<WGM10)
#endif
;
#endif
#if defined(_ICNC1) || defined(_ICES1) || defined(_WGM1) || defined(_CS1)
TCCR1B=0
#ifdef _ICNC1
| (_ICNC1<<ICNC1)
#endif
#ifdef _ICES1
| (_ICES1<<ICES1)
#endif
#ifdef _WGM1
| ((WGM1>>2)<<WGM12)
#endif
#ifdef _CS1
| (_CS1<<CS10)
#endif
;
#endifКод: Выделить всё
TCCR1B=(_ICNC1<<ICNC1) | (_ICES1<<ICES1) | ((_WGM1>>2)<<WGM12) | (_CS1<<CS10);
...
#ifdef _WGM1
| ((WGM1>>2)<<WGM12)
#endifКод: Выделить всё
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1200,000 kHz
#define _CS1 1
// Mode: CTC top=OCR1A
#define _WGM1 4
// OC1A output: Disconnected
#define _COM1A 0
// OC1B output: Disconnected
#define _COM1B 0
// Noise Canceler: Off
#define _ICNC1 0
// Input Capture on Falling Edge
#define _ICES1 0
// Timer1 Overflow Interrupt: Off
#define _TOIE1 0
// Input Capture Interrupt: Off
#define _ICIE1 0
// Compare A Match Interrupt: Off
#define _OCIE1A 0
// Compare B Match Interrupt: Off
#define _OCIE1B 0
#include <tiny2313_peripheral_init.c>Код: Выделить всё
uint8_t count __attribute__ ((section (".noinit")));Код: Выделить всё
uint8_t count __attribute__ ((section (".noinit")));Код: Выделить всё
uint8_t count __attribute__ ((section (".noinit")));Подскажите пожалуйста, скажем после сброса сторожевым таймером, мне скорее всего нужно в регистре управления MCUCSR два бита WDRF(Флаг индикации сброса сторожевым таймером) и PORF(Флаг Сброса включении питания), чтобы понимать МК как он именно сбросился. Потом, поняли что сторожевым таймером, биты сбросить в 0. Далее самое интересно, где это делаетcя int main?ARV писал(а):считать таймер в переменных, не очищаемых при сбросе МК
Код: Выделить всё
#include "main.h"
#define F_CPU 8000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/wdt.h>
uint8_t state_error __attribute__ ((section (".noinit")));
uint8_t state_status __attribute__ ((section (".noinit")));
uint8_t state_status_2 __attribute__ ((section (".noinit")));
void sensor(void);
int main(void)
{
if(MCUCSR&(1<<WDRF)){ MCUCSR&=~(1<<WDRF);}
if(MCUCSR&(1<<PORF)) {MCUCSR&=~(1<<PORF);}
Port_Init();
Timer_Init();
sei();
wdt_enable(WDTO_1S);
while (1) {
wdt_reset();
sensor(); //опрос датчиков уровня воды
if(state_status == 1){
PORTD |= (1<<RELAY_PUMP); //вкл насос
}else{
PORTD &=~ (1<<RELAY_PUMP); //выкл насос
}
}
}