Hi, please find the attached file and help me where is an error.
The working of code:
The code execute when INTERRUPT Pin detects the RISING edge of trigger signal.
It goes to ISR called "aa" here, DISABLE The INTERRUPT (cli) and acquire 320 samples and store in the buffer called dataArray[320]
3)After that it Prints 320 data on serial window and wait for 5 Seconds then ENABLE the Interrupt, and wait for the another Interrupt signal.
The problem i am facing is.
it prints 320 buffer actual data, and 320 buffer data shows 0 only Total 620. means the ISR active for 2 times. or For loop Execute 2 times. i am not able to find out what happenings.
2)Actually it must print 320 Buffer data on serial window. i am giving trigger signal from another UNO that is for 1 mS pulse.
why it prints total 620 data when buffer size is only 320????
ISRs should be short portions of code that run as quickly as possible, which is not the case here. They should be used only when a portion of code absolutely must be executed NOW
Your ISR has 320 delay(10)'s in it amounting to 3.2 seconds. Even if that was a good idea, why not use a for loop instead of 320 copies of the same code ? In addition, delay() and Serial printing do not work inside an ISR or is they do they do not work properly because they depend on interrupts, which are automatically disables when in an ISR so you don't need to do it yourself.
Why use an interrupt in the first place ? Detect the pin going HIGH and run a for loop to collect the data. No need for an ISR in the first place.
That is a crazy way to use an interrupt. An ISR should be designed to complete very quickly - something like
void aa() {
newInterrupt = true;
}
an the rest of the code should take place outside the ISR.
And you MUST learn about arrays. You have about 650 lines of code in your function and that could probably all be done in 5 lines with much less chance of typing errors.
Then it would be wise to learn how to do timing without using delay(). Have a look at how millis() is used to manage timing without blocking in Several things at a time
it prints 320 buffer actual data, and 320 buffer data shows 0 only Total 620. means the ISR active for 2 times. or For loop Execute 2 times. i am not able to find out what happenings.
2)Actually it must print 320 Buffer data on serial window. i am giving trigger signal from another UNO that is for 1 mS pulse.
why it prints total 620 data when buffer size is only 320????
But, as already stated, your problem does not need interrupts.
Using interrupts for keys makes it harder to debounce the keys,
but you forgot that you have to handle debouncing anyway.
The IDE has examples for reading a key and detecting a state change on a pin.