Page 1 of 1

Cannot control the default CS0 pin on VSPI.

Posted: Tue Jul 16, 2019 9:58 pm
by catotonic
I am trying to interface with an external 16bit ADC. I need to enable CS0 pin 5, 12 uSec before transferring data. So I need the pin to stay default low, go high to start the conversion, and then go low to acquire data. The default operation is to stay high until ~1uSec before a transfer starts.
The operation I need is:

Code: Select all

while(samplesAcquired < numSmpls) {
	digitalWrite(5,HIGH); 
	ets_delay_us(CNVRT_TIME);// Spec Sheet says we need 8.8uSec to convert
	digitalWrite(5,LOW);
	SPI_GetUInt16(&this->ads8866Data);//Apply bias here so that signal is ready for window
	glbAcqBuff.intArray[samplesAcquired] = ads8866Data;
	ets_delay_us(ticksPerSample);
	samplesAcquired++;
}

//in VSPI_init()
 devcfg.spics_io_num = -1;//=PIN_NUM_CS;     Disable CS0 in VSPI          //CS pin
 
 //In board setup Enable CS as GPIO
 pinMode(pinNum, INPUT);
digitalWrite((gpio_num_t)pinNum,LOW);
But the CS pin just stays high.
The simple solution is to use another pin, but I am using every pin on the board and cannot afford a unused pin.
Is there some other controls for the CS pin or a way to disable it and give me manual control?

Re: Cannot control the default CS0 pin on VSPI.

Posted: Wed Jul 17, 2019 3:38 am
by mikemoy
//In board setup Enable CS as GPIO
pinMode(pinNum, INPUT);
You have the CS pin set as a input.

Re: Cannot control the default CS0 pin on VSPI.

Posted: Wed Jul 17, 2019 4:31 am
by catotonic
@Mikemoy
Thanks for responding.
If only I had been that stupid, I would be embarrassed, but happy that you found the problem. But no, I was just tired and not paying attention.
I was just copying and pasting code to avoid typing, before I ran out the door.
I have pinMode in two different functions, one for inputs and one for output that are called elsewhere,
The line that calls the pinMode(pinNum, Output){} is: InitPinAsOutput(ADC_CNVRT);
Thanks for the catch, my eyes were tired.