This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL2-TMS57012: ADC hardware_triggering using GIO

Part Number: LAUNCHXL2-TMS57012
Other Parts Discussed in Thread: HALCOGEN

i want to start conversion of ADC(ambient_lightsensor[AD1IN_6]) with external input  by setting the voltage of one of GIO pins to high from almost zero  (3.3v or 5v) . i configure the halcogen as below :

drivers : GIO / SCI2LIN (for serial transmission of sampled voltage) / ADC1 

GIO : port b bit 0  : set to rising edge and enable connection to VIM.

PINMUX : enable GIOB and AD1EVT (may be not needed at all ) 

ADC1 Group Event  : ADC1 Group trigger source GIOB0 on default and Trigger edge to rising edge. / enable pin 6 for voltage sampling of ambient light sensor(on this very board) . 

and this is my code in sys_main.c 

int main(void)
{
    //initializing SCI module
    sciInit() ;

    //initializing ADC module
    adcInit() ;

    //initializing GIO module
    gioInit() ;


    uint32 grp = 1 ;
    adcData_t adc_dat ;
    adcData_t * pr_adc_dat = &adc_dat ;
    uint32 num_digit = 0 ;
    char ch[10] ;
    char* pr_ch = &ch[0] ;

    //fist comment // 
    sciSend(scilinREG , 24 , "Ambient Light Viewer :\r\n") ;
    while(1){

        while(adcIsConversionComplete(adcREG1 , 1) == 0) ;
        adcGetData(adcREG1 , 1 , pr_adc_dat ) ;
        num_digit = ltoa(pr_adc_dat->value, pr_ch) ;
        sciSend(scilinREG , 2 , "v:" ) ;
        sciSend(scilinREG , num_digit , pr_ch )  ;
        sciSend(scilinREG , 2 , "\r\n") ;
        //after each iteration set the isconversioncomplete to false ...
        //wait until again GIOB0 voltage set to HIGH (3.3 or 5) ... 
        adcREG1->GxINTFLG[grp] = (uint32) 0U ;
    }
    return 0;
}

im not examining the SCI module because it works for the first comment ( refer to code) ... 

i have no idea why when i set GIOB_0  to HIGH logical value externally the conversion is not begin( note that i leave the GIOB_0 pin with it's default input direction). 

  • Hello,

    The Event Group is only hardware-triggered. The Event Group conversion starts when at least one channel is selected for conversion in this group, and when the defined event trigger (GIOB_0) occurs.

    Please add this statement just above the while(1) loop:
    adc->GxSEL[0] = s_adcSelect[0U][0];
  • hi ... tnx for the reply ... i thought this is done by the adcInit() ... 

    i resolve it by 

    adcREG1->GxSEL[1] = 0x00000040U ;

    now the triggering and reporting is ok but it is always reports same value . there is some problem with the previous code which i modified it as below ... 

    int main(void)
    {
        //initializing SCI module
        sciInit() ;
    
        //initializing ADC module
        adcInit() ;
    
        //initializing GIO module
        gioInit() ;
    
    
        uint32 grp = 1 ;
        adcData_t adc_dat ;
        adcData_t * pr_adc_dat = &adc_dat ;
        uint32 num_digit = 0 ;
        unsigned char ch[10] ;
        sciSend(scilinREG , 24 , "Ambient Light Viewer :\r\n") ;
        adcREG1->GxSEL[1] = 0x00000040U ;
        while(1){
    
            while(adcIsConversionComplete(adcREG1 , 1) == 0) ;
            adcGetData(adcREG1 , 1 , pr_adc_dat ) ;
            num_digit = ltoa(pr_adc_dat->value,(char*)ch) ;
            sciSend(scilinREG , 2 , "v:" ) ;
            sciSend(scilinREG , num_digit , ch)  ;
            sciSend(scilinREG , 2 , "\r\n") ;
            //after each iteration set the isconversioncomplete to false ...
            //mimic the fact that no adc output request sent
            adcREG1->GxINTFLG[grp] = (uint32) 0U ;
        }
        return 0;
    }

    Update : i resolve above problem by this  piece of code .... 

    
    
    int main(void)
    {
        //initializing SCI module
        sciInit() ;
    
        //initializing ADC module
        adcInit() ;
    
        //initializing GIO module
        gioInit() ;
    
    
        uint32 grp = 1 ;
        //adcData_t adc_dat ;
        //adcData_t * pr_adc_dat = &adc_dat ;
        uint32 num_digit = 0 ;
        uint16 val ;
        unsigned char ch[10] ;
    
        sciSend(scilinREG , 24 , "Ambient Light Viewer :\r\n") ;
        adcREG1->GxSEL[1] = 0x00000040U ;
    
        while(1){
    
            while(adcIsConversionComplete(adcREG1 , 1) == 0) ;
    
    
            val = (uint16)(adcREG1->GxBUF[grp].BUF0 & 0xFFFU) ;
            num_digit = ltoa(val,(char*)ch) ;
            sciSend(scilinREG , 2 , "v:" ) ;
            sciSend(scilinREG , num_digit , ch)  ;
            sciSend(scilinREG , 2 , "\r\n") ;
            //after each iteration set the isconversioncomplete to false ...
            //mimic the fact that no adc output request sent
            adcREG1->GxINTFLG[grp] = (uint32) 0U ;
        }
        return 0;
    }
    

    one thing which i learned is that aside from halcogen you should know all the registers which is used by halcogen API and their function definitions and modified best for your purpose ....