Hi,
Well, that too defeats the purpose of using the interrupt in the first place since you trig the conversion and sit around waiting for it to complete while IN the interrupt handler. You could just as well have used ADCIN in the ISR.
One thing we need to get squared away just so we're clear. Your ISR is called ADC_Change and from that I get the feeling that you might think the ADC interrupt fires when the voltage at the input changes - that's not the case. If that was already obvious to you then I appologise, I just wanted to clarify that.
You start the conversion from within your main code or possibly from another ISR, whatever. Then, instead of sitting around waiting for the duration of the conversion you go do something else or go to sleep to provide a quiet environment for the ADC. The interrupt then fires when the conversion is complete and all you need to do in the ISR is grab the result by reading ADRESH, just like you're doing now.
As you probably know using, when using DT-ints, PBP needs to do a whole lot of context saving/restoring when entering/exiting the ISR and this takes time. So it might not even be worth it using interrupts as the time taken to enter and exit the ISR could very well be longer than the ADC conversion time. I don't know for sure, and it depends, just saying..... If reading the result is all you're going to do in the ISR then you can probably get away with an ASM type handler still written in PBP which will be much quicker to get in and out of - but that's always "risky" so lets not go there untill you have something that works and does what you need.
/Henrik.
Bookmarks