Cannot control the default CS0 pin on VSPI.

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Cannot control the default CS0 pin on VSPI.

Postby catotonic » Tue Jul 16, 2019 9:58 pm

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?

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: Cannot control the default CS0 pin on VSPI.

Postby mikemoy » Wed Jul 17, 2019 3:38 am

//In board setup Enable CS as GPIO
pinMode(pinNum, INPUT);
You have the CS pin set as a input.

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Re: Cannot control the default CS0 pin on VSPI.

Postby catotonic » Wed Jul 17, 2019 4:31 am

@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.

Who is online

Users browsing this forum: No registered users and 50 guests