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.

ADS7951 serial communications

Other Parts Discussed in Thread: ADS7951

hello,

   I'm using a ADS7951 with each channel connected to an 8 to 1 multiplexer. I'm controlling the multiplexer with the four GPIO pins. I have pull up resistors attached to all four of the GPIO lines. I believe that I program the GPIO correctly because I somehow assert GPIO4 low but for some reason I cannot change the level of the other 3. My SPI port is set to transmit at 5MHz. I believe the Error may be somewhere in my code posted below.

 

/**************************************************************************************************/
/* description    intialization routine for shift reg.                                            */
/* input          -                                                                               */
/* output         -                                                                               */
/**************************************************************************************************/
void EADC_Init()
/**************************************************************************************************/
{
  _TRISG9 = 0;                                        //sets up the CS# pin
  _LATG9 = 1;                                         //set initial values
 
  _LATG9 = 0;
  SPI_send(2,0x0000);                                 //send an empty transmission
  _LATG9 = 1;
 
  int i;
  for(i=0;i<50;i++){Nop();}
 
  _LATG9 = 0;
  SPI_send(2,0x400F);                                 //sets all GPIO pins to outputs
  _LATG9 = 1;
} //EADC_Init

/**************************************************************************************************/
/* description    intialization routine for shift reg.                                            */
/* input          -                                                                               */
/* output         -                                                                               */
/**************************************************************************************************/
unsigned int EADC_get(unsigned int channel)
/**************************************************************************************************/
{
  unsigned int proxy = 0;
  unsigned int test = channel;
  proxy = proxy | (0x1840);
  proxy = proxy | ((channel & ~(0xFF87))<<4);
  proxy = proxy | (test & ~(0xFFF8));
  _LATG9 = 0;
  SPI_send(2,proxy);
  _LATG9 = 1;
 
  int i;
  for(i=0;i<50;i++){Nop();}
 
  _LATG9 = 0;
 unsigned long int answer = SPI_send(2,proxy);
  _LATG9 = 1;
  answer = answer & 0x0FFF;
  answer = (answer*2500)/2048;
  return (int)answer;
} //EADC_get

if you need any other information that i did not already say please ask. I'm happy to provide any information that may help me fix this problem.

Thanks,

  Steve

  • Hi Steve,

    While we look over the code, can you possibly post screen shots of your SPI interface?

  • Hi Tom,

    /**************************************************************************************************/
    /* description    sends the arguments out the SPI port                                            */
    /* input          -                                                                               */
    /* output         -                                                                               */
    /**************************************************************************************************/
    unsigned int SPI_send(unsigned int channel, unsigned int input)
    /**************************************************************************************************/
    {
      if(channel == 1){
        SPI1BUF = input;
        while(SPI1STATbits.SPIRBF == 0);
        return SPI1BUF;
      }
      else if(channel == 2){
        SPI2BUF = input;
        while(SPI2STATbits.SPIRBF == 0);
        return SPI2BUF;
      }
      else{
      }
      return 0xFFFF;
    } //SPI_send

    basically I ask for what channel to send on and what to send. Then I return what was received.

    Thanks,

      Steve

  • Steve,

    Unless I missed something here, you haven't mentioned what platform this code is resident on. MSP430? Is this a PIC?

    As Tom asked, some oscilloscope captures of this interface would really be the best way for us to help you debug your problem. If we can see the serial lines (i.e. what's actually happening) we can begin to diagnose the problem much better and then work on figuring out what needs to change in your code.

  • Ah, Sorry. I'm using this on a Microchip PIC24HJ256GP610A I will try and post oscilloscope pictures of the SPI tomorrow. I currently don't have any way of posting them. I'll bring my camera to work tomorrow.

    Thanks,

      Steve

  • Hello,

     Sorry about the wait but I have found the error. The code for my SPI operation had an error with the Recieved Word Flag. I was transmitting but I wasn't waiting till the transmission ended. Which in turn caused my Chip Select pin to go low to early.

    Thanks for all the help,

     Steve Rinckel

  • Hi Steve,

    Can you please share the solution/driver ?

    Thanks,
    Ran