Forum: Mikrocontroller und Digitale Elektronik operation timing of single shot mode


von Adam s. (wassimsb)


Lesenswert?

kann jemand hier mir helfen bei programmierung da ads1015 in single shot 
mode statt in countiousl mode programmieren will.
ads1015 datashett lautet;
the ADS1015 wait until the OS bit is set high. Once asserted, the bit is 
set to '0', indicating that a conversion is currently in progress. Once 
conversion data are ready, the OS bit reasserts and the device powers 
down. Writing a '1'to the OS bit during a conversion has no effect.

in single-shot  mode:

uint16 read_ads( uint8 address )
{
uint16 analog_val ;

  analog_val = (int16)i2c_read( I2C_ADS1015, address, 1, ADSREG_CONV, 0, 
0 );

  if( analog_val < 0 )
    analog_val = 0 ;
  return( analog_val );
}

uint16 read_status(void)
{
tp_ads1015_config config_str;
uint16 config_reg ;
  return(config_str.os,0x0000);   // OS_RDY =1 WHEN CONVERSION  IN 
PROGRESS

}

void hal_adc_tick(void)

{
#ifdef I2C_ADC
static uint8  ad_ch ;
#endif
delay_10us(50);
  ADC12CTL0 |= ADC12SC;             // restart conversion


#ifdef I2C_ADC
start_ads( 0, 0 ) ;  // START CONVERSION
  while( ad_ch < (LENGTH( hal_adc ) -1 ))
    hal_adc[ad_ch+1] = read_status( ad_ch >> 2 ) ;

  ad_ch++ ;
return read_status(ad_ch >> 2 );        // Read out conversion result

  //if( ad_ch >= I2C_ADC )
    //ad_ch = 0 ;

  //start_ads( ad_ch >> 2, ad_ch ) ;
}
#endif

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.