Hello
I use intterupt and after interrupt stuff i need reset pro mini Atmega328p .
But I tried reset func after send data via serial . if i use reset func or wdtenable serial communication serial data is missing .
How can i do reset / reboot with correctly?
reset func:
void(* resetFunc) (void) = 0;
interrupt:
attachInterrupt(digitalPinToInterrupt( 2 ), gonder, FALLING);
....
void gonder(){
if((millis() - son_intterupt) > 150){
Serial.begin(115200);
while(!Serial){;}
String giden = String(counter);;
Serial.println(giden);
// Serial.println("reset onu.");
// wdt_enable(WDTO_15MS);
resetFunc();
Serial.println("not print...");
}
}
Best regards.
Why?
Please post complete code.
1 Like
void(* resetFunc) (void) = 0;
void setup() {
// disable ADC
ADCSRA = 0;
//asm volatile("jmp 0");
Wire.begin();
//Turning on the ADXL345
writeTo(DEVICE, 0x2D, 0);
writeTo(DEVICE, 0x2D, 16);
writeTo(DEVICE, 0x2D, 8);
//pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt( 2 ), gonder, FALLING);
}
void loop() {
.....
}
void gonder(){
if((millis() - son_intterupt) > 150){
Serial.begin(115200);
while(!Serial){;}
String seri_nu = "4321";
String giden = seri_nu +"-"+ String(adim) ;;
Serial.println(giden);
adim = 0;
son_intterupt = millis();
resetFunc();
}
}
You haven't explained why you want the reset.
Your code is not complete.
Your code is not complete, but this
while(!Serial){;}
must be your issue.
Do not use Serial within an ISR, since interrupts are disabled within it.
The connection to the UART can never be true if it is waiting for an interrupt that can never be registered.
1 Like
On a ProMini, Serial
is always true. It however brings the question why OP does a Serial. begin in an ISR.
1 Like
if i active in setup hardware Serial, is it increase power consumption?
i am willing to reduce power consumption . mcu gives data every hour by Serial so which method is benefits?
system
Closed
November 19, 2022, 11:44am
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.