spurious low pulse on SPI0:CS output
Posted: Wed Nov 02, 2022 3:41 am
Due to the shortage of Raspberry Pi's I bought a beaglebone black, and am trying to move my python code to the new platform. This code uses the SPI port to communicate with a battery management chip.
During testing I found that not only do you have to manually re-allocate the function of the SPI port pins with config-pin (os calls), but also the CS pin has a spurious pulse, identical to that found with the spidev driver used on the raspberry pi. https://github.com/doceme/py-spidev/issues/113 has the details and the cure - which was commenting out some lines of C code in the driver module, and re-compiling. I suspect that the Adafruit BBIO code needs the same fix. However, there does not seem to be a link to the source code for the Adafruit module, so the fix must come from the module maintainer.
source code snipit:
// WA:
// in CS_HIGH mode CS isn't pulled to low after transfer, but after read
// reading 0 bytes doesnt matter but brings cs down
// tomdean:
// Stop generating an extra CS except in mode CS_HOGH
if (self->mode & SPI_CS_HIGH) status = read(self->fd, &rxbuf[0], 0);
the above line needs to be commented out for sip.xfer, spi.sfer2.
Open source coding is wonderful - the same bugs show up in many places!!!
Mike.
During testing I found that not only do you have to manually re-allocate the function of the SPI port pins with config-pin (os calls), but also the CS pin has a spurious pulse, identical to that found with the spidev driver used on the raspberry pi. https://github.com/doceme/py-spidev/issues/113 has the details and the cure - which was commenting out some lines of C code in the driver module, and re-compiling. I suspect that the Adafruit BBIO code needs the same fix. However, there does not seem to be a link to the source code for the Adafruit module, so the fix must come from the module maintainer.
source code snipit:
// WA:
// in CS_HIGH mode CS isn't pulled to low after transfer, but after read
// reading 0 bytes doesnt matter but brings cs down
// tomdean:
// Stop generating an extra CS except in mode CS_HOGH
if (self->mode & SPI_CS_HIGH) status = read(self->fd, &rxbuf[0], 0);
the above line needs to be commented out for sip.xfer, spi.sfer2.
Open source coding is wonderful - the same bugs show up in many places!!!
Mike.