AnsweredAssumed Answered

How to use the PDB external trigger to control the ADC conversion?

Question asked by Liu KunYen on Jul 7, 2017


function: ADC transformation, use the PDB external trigger,


The problem is as below.
How to set the PDB external trigger conditions(positive edge/negative edge),
I even trig pin with Vcc directly,simulate positive edge, but no ADC convertion.


I even set the related register , but there is no corresponding action,
the situation is the same(it's invalid).
Port initilaize:
     PORT_SetPinMux(PORTC, PIN0_IDX, kPORT_MuxAlt3);


SIM Configuration is below:
        SIM->SOPT7 &= ~(SIM_SOPT7_ADC0ALTTRGEN_MASK  | // selects PDB not ALT trigger
                    SIM_SOPT7_ADC0PRETRGSEL_MASK) ;


  Programmable Delay Block assignment:  
        PDB0->SC &=  ~(PDB_SC_CONT_MASK);//one-shot, mode
        PDB0->SC |= (PDB_SC_PDBEN_MASK       // PDB enabled
              | PDB_SC_PDBIE_MASK       // PDB Interrupt Enable
              |  PDB_SC_PRESCALER(0x1)   // Slow down the period of the PDB for testing
              | PDB_SC_TRGSEL(0x0)      // Trigger source is Software Trigger to be invoked in this file
              | PDB_SC_MULT(2));          // Multiplication factor 20 for the prescale divider for the counter clock


                PDB0->IDLY = 0x00;     // need to trigger interrupt every counter reset which happens when modulus reached
               PDB0->MOD = 0x40;     // largest period possible with the slections above, so slow you can see each conversion.


                 PDB0->CH[0].C1 = PDB_C1_EN(0x01)| PDB_C1_TOS(0x01);


                  PDB0->CH[0].DLY[0] =  0x02;
                    PDB0->CH[0].DLY[1] =  0x04;


                     PDB0->SC |=  PDB_SC_LDOK_MASK;       // Need to ok the loading or it will not load certain regsiters!
                     // the software trigger, PDB_SC_SWTRIG_MASK is not triggered at this time
      ADC assignment for PDB trig is below
                      ADC0->SC2 |= ADC_SC2_ADTRG_MASK


Please help me , it's a urgent case. thanks for your reading.