SPI bit banging; MCP3208; Raspberry;error

Discussion in 'Embedded Systems and Microcontrollers' started by Vindhyachal Takniki, Jul 14, 2015.

  1. Vindhyachal Takniki

    Thread Starter Member

    Nov 3, 2014
    348
    6
    1. I am using raspberry pi 2 board with raspbian loaded. need to do SPI by bit banging & interface MCP3208.
    2. I have taken code from here, it is written for MCp3008(10 bit adc):
    https://github.com/raspberrypi-aa/raspberrypi-aa/blob/master/spi_bitbang_test.py

    3. Only change i had made in code is instead of calling
    adcValue = recvBits(12, clkPin, misoPin)

    I had called
    adcValue = recvBits(14, clkPin, misoPin)

    Since have to receive 14 bits of data.

    4. Problem is code is not working. It keeps on sending random data ranging from 0-10700. Even though data should be max 4095. It means I am not reading data correct.

    5. Problem which I think is since MCP3208 has max freq = 2Mhz , but in code there is no delay between two consecutive data read or write. I think I need to add some delay of 0.5us whenever I need to transition clock sicen I am operating at 1Mhz.

    6. For some delay I am currently reading these:
    https://projects.drogon.net/accurate-delays-on-the-raspberry-pi/
     
Loading...