Hello,
I`ve been trying to read from an ADS8361 using a RaspberryPi 3 but I haven`t been able to get anything but zeros. I don`t have an logic analyser but with an oscilloscope it looks like there is an output being generated, so probably there is something wrong with my code.
At this point I`m not entirely sure it applies to this one, but the program starts similar to other converter`s:
if (!bcm2835_init()) { return 1; }
bcm2835_gpio_fsel(CONVST_PIN, BCM2835_GPIO_FSEL_OUTP); //BCM2835_GPIO_FSEL_OUTP=>Output 0b001
bcm2835_gpio_write(CONVST_PIN, LOW);
bcm2835_gpio_fsel(BUSY_PIN, BCM2835_GPIO_FSEL_INPT); //BCM2835_GPIO_FSEL_INPT=>Input 0b000
bcm2835_spi_begin();
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);
bcm2835_spi_setDataMode(BCM2835_SPI_MODE1); // The default CPOL = 0, CPHA = 0
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_32 );
bcm2835_spi_chipSelect(BCM2835_SPI_CS0);
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW);
Followed by a loop in which the writing and reading was suppose to happen.
I tried:
bcm2835_gpio_write(CONVST_PIN, HIGH);
bcm2835_spi_transfern(Buffer_A, sizeof(Buffer_A));
bcm2835_gpio_write(CONVST_PIN, LOW);
And:
bcm2835_gpio_write(CONVST_PIN, HIGH);
bcm2835_gpio_write(CONVST_PIN, LOW);
buffer[0] = bcm2835_spi_transfer(0x00);
buffer[1] = bcm2835_spi_transfer(0x00);
buffer[2] = bcm2835_spi_transfer(0x00);
read = ((uint32_t)buffer[0] << 16) & 0x00FF0000;
read |= ((uint32_t)buffer[1] << 8);
read |= buffer[2];
And I made small changes, ran it a bunch of times,I tried different modes, tried delays but the results have been always the same, its not giving me anything to work with.
I think I might be doing the timing and synchronisation wrong, I`ve been trying to get my head around on how to do it properly but so far nothing. I would be a great help if anyone could show the right way to do it.
Best Regards,
Pedro