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