확인아두 이노 Interuppt 및 수면은 그 정보가 필요한 경우 내가 마이티 Optiboot 부트 로더와 아트멜 (Atmel) 1284P를 사용하고
동결된다.
저는 개별적으로 작동하는 각각의 것들을 얻을 수 있지만 함께 모으는 순간 매우 이상한 결과를 얻습니다.
RTC DS3231을 Arduino 절전 기능과 함께 사용하려고하고 있으며 RTC로부터 인터럽트를 일으켰습니다. (리얼 타임 클럭) 내 마이크로 인터럽트 핀에 연결된 RTC의 SQW 핀.
이 모든 것들은 혼자 할 때 잘 작동하지만 일단 조립하면 코드가 멈추고 계속되지 않습니다.
내 코드는 다음과 같습니다. 저는 매분마다 마이크로를 깨우려고합니다. 글로벌 var T는 대기 시간입니다.
#include <avr/sleep.h>
#include <avr/power.h>
#include <Wire.h>
#include "ds3231.h"
struct ts t; // The Time structure
int T = 1; // The sleeping time in minutes
void setup()
{
pinMode(2,INPUT); // my interuppt is on pin 2
Serial.begin(9600);
Wire.begin();
DS3231_init(DS3231_INTCN); // Start the RTC interface
}
void loop()
{
Serial.println("Running"); // something to see that the micro is wake for a bit and not frozen
delay(5000); // a delay in my main code I will be loggin data
set_next_alarm(); /// set the next RTC alarm
DS3231_clear_a2f(); // clear a2 alarm flag and let INT go into high ,,, disabling the interrupt
sleep_enable(); // get sleep ready
attachInterrupt(2,wakeUp, LOW); // set the interrupt things
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is power down for most power savings
cli();
sei();
sleep_cpu(); // Sleeps here
sleep_disable(); // Wakes up here
// I have ccopied this bit of the sleeping code from the arduino fourums
}
void wakeUp() // run when interrupt is called
{
detachInterrupt(2); // detach the interrupt
sleep_disable();
}
void set_next_alarm(void) // Set the next alarm here
{
unsigned char wakeup_min;
DS3231_get(&t); // get the current time
// calculate the minute when the next alarm will be triggered
wakeup_min = (t.min/T + 1) * T;
if (wakeup_min > 59) {
wakeup_min -= 60;
}
boolean flags[4] = { 0, 1, 1, 1 };
DS3231_set_a2(wakeup_min, 0, 0, flags); // set the alarm 2
// activate Alarm2
DS3231_set_creg(DS3231_INTCN | DS3231_A2IE);
}
그러나 코드가 실행될 때 고정 된 프로그램이 실행되고 RTC에서 알람이 트리거됩니다. SQW 핀에 LED를 놓고 LOW로 표시 되었기 때문에 RTC가 트리거된다는 것을 알고 있지만 RTC는 핀을 LOW로 유지하므로 아무 일도 일어나지 않습니다.
좋은 아이디어 나 도움을 주시면 감사하겠습니다. 좋은 3 주를 보냈지 만 여기에는 단서가 없습니다.
attachInterrupt (2, wakeUp, LOW);'a) 여기에 올바른 인터럽트/핀이 있는지 확인 하시겠습니까? b) "하지만 RTC가 핀을 하이로 유지"- 왜 LOW에 대한 인터럽트를 설정합니까? - 레벨 인터럽트는 장치를 "유휴"상태에서 깨우지 못합니다. - "유휴"절전 모드를 사용하면 아무것도 변경되는지 확인하십시오. – JimmyB
죄송합니다. 내 실수는 RTC가 핀을 LOW로 유지한다고 말하는 것입니다. – Spider999
나는 게시물에서 그것을 바 꾸었습니다. 또한 내가 꽤 잘못 읽는 않는 한 데이터 시트를 이중 및 삼중으로 확인했기 때문에 첨부 진술이 정확하다는 것을 확신합니다. – Spider999