Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: reading MISO

  1. #1
    Senior Member
    Join Date
    Sep 2015
    Posts
    102

    reading MISO

    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

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,758
    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...

  3. #3
    Senior Member
    Join Date
    Sep 2015
    Posts
    102
    Thank you

    thats great information.

    I won't make that mistake again,,,,

    Have good weekend

  4. #4
    Senior Member bmillier's Avatar
    Join Date
    Apr 2016
    Location
    Halifax, N.S. Canada
    Posts
    163
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •