reading MISO

Status
Not open for further replies.

drjohnsmith

Well-known member
Have a ADC AD7193 chip, which is SPI , ish.

In particular the adc , uses its MISO pin , to indicate its ready.

in effect one does the spi transfer,
and then waits, with chip select still low, till the AD7913 takes MISO low.

then one can do the second transfer, and take chip select high.


I thought, digitalread( pin number of miso )
but that seems to always be returning high.

lots of testing to do, like get the scope out etc,
but anyone have any thoughts if one can read the MISO pin if its been defined in the SPI class.

using the normal SPI.h , on a teensy 3.6


Thanks
 
Yes, when you are in SPI, the IO pins are configured such that MUX for that pin is in mode(2), whereas for digital input/output needs to be in mode(1)

You could probably get away with hacking the mode of the pin to handle this. Maybe something like:
Code:
    CORE_PIN12_CONFIG = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
    digitalRead(12);
    CORE_PIN12_CONFIG = PORT_PCR_MUX(2);
This assumes pin 12 as your MISO, obviously would need to change if you are using different pins. Also first part you might get away with calling pinMode:
Code:
    pinMode(12, INPUT); // or INPUT_PULLUP or ...
    digitalRead(12);
    CORE_PIN12_CONFIG = PORT_PCR_MUX(2);

Again not sure how well this would work, but...
 
I've used such ADCs where the MISO pin is also used for ready status. I had spare GPIO pins, so I just wired an additional MCU GPIO pin to the ADC MISO pin, set that added GPIO for input, and polled the ready status by checking that other GPIO pin's state. Eliminates fooling around with the MCUs MISO pin's mode.
 
Status
Not open for further replies.
Back
Top