Quantcast
Channel: Data converters
Viewing all articles
Browse latest Browse all 91538

Forum Post: ADS 8345 interface with LM3s6965 Help!

$
0
0

Hello! I'm working with 2 channels  of the  ADC8345EVM (16bits )  and when I show the  channel 1 value on OLED display  it´s change with channel 0.

The other question is  that  the value show it's wrong. (0V=57680 and 5V=25312)

What's wrong?

Thanks for help!

Look the code beelow;

//**********************************************************************************************************************************************

void config_adc_ssi(unsigned long ulFrequency)
{
 SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);  
 SSIDisable(SSI0_BASE);
 GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_4 |GPIO_PIN_3);
 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3,
                     GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
 SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(),SSI_FRF_MOTO_MODE_3 , SSI_MODE_MASTER,1000000, 16);
 GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);
 GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);
 SSIEnable(SSI0_BASE);
}

void start_read_adc(unsigned long channel)
{
 SSIDisable(SSI0_BASE);      
 GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_4 |GPIO_PIN_3);
 SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(),SSI_FRF_MOTO_MODE_3 , SSI_MODE_MASTER,1000000, 16);
 GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, 0);
 SSIEnable(SSI0_BASE);         
 SSIDataPut(SSI0_BASE,channel);
 while(SSIBusy(SSI0_BASE))
 {
 }
}
void stop_read_adc(void)
{
  unsigned long ulTemp;
 GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_PIN_6);
 while(SSIDataGetNonBlocking(SSI0_BASE, &ulTemp) != 0)
 {
  }
}

int
main(void)
{
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
  RIT128x96x4Init(1000000);
  config_adc_ssi(1000000);
  while(1)
  {
   // read  channel 0 and show on OLED display
   start_read_adc(0x87);
   SSIDataGetNonBlocking(SSI0_BASE, &read_value);
   stop_read_adc();
   RIT128x96x4Enable(1000000);
   usprintf(szBuffer,"%010d",read_value);
   RIT128x96x4StringDraw(szBuffer,40, 24, 15);
   RIT128x96x4StringDraw("Ch_0:", 1, 24, 15);
   usprintf(szBuffer,"%010d",0);
   RIT128x96x4Disable();
   SysCtlDelay(1000);
   // read  channel 1 and show on OLED display
   start_read_adc(0xC7);
   SSIDataGetNonBlocking(SSI0_BASE, &read_value);
   stop_read_adc();
   RIT128x96x4Enable(1000000);
   usprintf(szBuffer,"%010d",read_value);
   RIT128x96x4StringDraw(szBuffer,40, 33, 15);
   RIT128x96x4StringDraw("Ch_1:", 1, 33, 15);
   usprintf(szBuffer,"%010d",0);
   RIT128x96x4Disable();
   SysCtlDelay(1000);
   }//while
}//main

//**********************************************************************************************************************************************

 


Viewing all articles
Browse latest Browse all 91538

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>