MPU is ESP32 devkit-C and AD converter is MCP3208.
I want to use HSPI. However, I cannot observe any signals from SCLK and MOSI. (The oscilloscope is made of Tektronix)
Is there something wrong?? I can't find it.
- #define ADC_CS 25
- #define MISO 12
- #define MOSI 13
- #define SCLK 14
- #define SS 15
- SPIClass hspi(HSPI);
- SPISettings settings = SPISettings(400000, MSBFIRST, SPI_MODE0);
- void InitializeSPI()
- {
- //SPI
- hspi.begin(SCLK, MISO, MOSI, SS);
- pinMode(ADC_CS, OUTPUT);
- pinMode( SCLK, OUTPUT);
- pinMode( MISO, INPUT);
- pinMode( MOSI, OUTPUT);
- pinMode( SS, OUTPUT);
- digitalWrite(ADC_CS, HIGH);
- }
- unsigned short ReadADC(char ch)
- {
- hspi.beginTransaction(settings);
- digitalWrite(ADC_CS, LOW);
- hspi.transfer(0x06 | ch >> 2);
- uint8_t highByte = hspi.transfer((ch & 0x03) << 6); // singleEnd
- uint8_t lowByte = hspi.transfer(0x00); // dummy
- digitalWrite(ADC_CS, HIGH);
- hspi.endTransaction();
- unsigned short adc = ((highByte & 0x0f) << 8) + lowByte;
- Serial.println("result value = " + String(adc, DEC));
- return adc;
- }