ATtiny1616 -> ADC0 Window Comparator Int won't fire

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Been on this one two hours now and still a no-go. ADC is using 0.55v ref, channel is correct, global ints enabled. I've give it a very low WINHT value just to be sure it'll be well within the firing range.

 

int8_t ADC0_Initialize()
{
     
    //DUTYCYC DUTY50; 
    ADC0.CALIB = 0x00;

    //SAMPNUM ACC1; 
    ADC0.CTRLB = 0x00;

    //SAMPCAP disabled; REFSEL INTREF; PRESC DIV256; 
    ADC0.CTRLC = 0x07;

    //INITDLY DLY0; ASDV ASVOFF; SAMPDLY 0; 
    ADC0.CTRLD = 0x00;

    //WINCM ABOVE; 
    ADC0.CTRLE = 0x02;

    //DBGRUN enabled; 
    ADC0.DBGCTRL = 0x01;

    //STARTEI disabled; 
    ADC0.EVCTRL = 0x00;

    //WCMP enabled; RESRDY disabled; 
    ADC0.INTCTRL = 0x02;

    //MUXPOS AIN10; 
    ADC0.MUXPOS = 0x0A;

    //SAMPLEN 31; 
    ADC0.SAMPCTRL = 0x1F;

    // Window comparator high threshold 
    ADC0.WINHT = 0x38;

    // Window comparator low threshold 
    ADC0.WINLT = 0x00;

    //RUNSTBY enabled; RESSEL 8BIT; FREERUN enabled; ENABLE enabled; 
    ADC0.CTRLA = 0x87;


    return 0;
}

 

ISR(ADC0_WCOMP_vect) {

    hvDetected = 1;
    ADC_DISABLE;
    ADC_CLEARINT;
}

Breakpoint on the ISR and start the ADC (freerunning mode)

 

ADC0.CTRLA |= ADC_ENABLE_bm;
ADC0.COMMAND = ADC_STCONV_bm

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With an Aref = 0.55v and a WINHT = 56 (0x38), the pin would need to have a voltage less than 0.03v to be IN the window, then I would assume a voltage over that would trigger the interrupt.

So what is the voltage right at the pin of the ADC input?

 

I would test this using Aref=VCC and a WINHT of say $1ff (or mid range).

Then have a pull down resistor on the pin and jumper in with vcc to trigger a test.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isn't there something in the 0/1 errata supplement about something not triggering off of something else?... sounds vaguely familiar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Apologies for my delay, juggling tasks.

I'll take a look. It's set to 'auto-trigger' repeatedly but is clocked of TMRA.

Measuring ~0.2v at the pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alright it's firing. I'm being burned by MPLABX like usual, it's frequently crashing and making a mess of indicating when breakpoints have been hit.

Attachment(s): 

Last Edited: Thu. Oct 1, 2020 - 10:50 PM