Is it possible to set the SPI word size to 16 bits in the bcm2835 library? The BCM2835 ARM Peripherals section 2.2.3 says the word size can be as much as 32 bits, but is there already a built in function somewhere in this library for changing it from 8 bits to says 16 bits. I'm making due with sending byte arrays instead, but it would make things more tidy and easier to match up with my device datasheet if I could just use 16 bit words.
--
You received this message because you are subscribed to the Google Groups "bcm2835" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bcm2835+u...@googlegroups.com.
To post to this group, send email to bcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/a4d5e19a-9f90-46aa-a298-9e5490c282c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
l = m % 36; // This just allows me to step through the 36 element array holding the DAC counts for 10 degree increments of a sine wave
eightBitWord[0] = sixteenBitWord[l] >> 8; // Load the upper 8 bits to first elementeightBitWord[1] = sixteenBitWord[l] & 0x00FF; // Load lower 8 bits to second elementbcm2835_spi_transfern(eightBitWord, 2U);
m++;
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/9ef89895-6865-46b0-8190-e6104817e31e%40googlegroups.com.
bcm2835_spi_chipSelect(BCM2835_SPI_CS1); bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS1, LOW); char mosi[4]={0x00,0b1000000000000,0x00}; // Don't care bit, 4096 value (i want a 5v output) and config bits bcm2835_spi_transfern(mosi,4);
myVoltage=readFromSPI(channel1); // I read successfully from a MCP ADC.
if(myVoltage<3.5) { increment++; }
if(myVoltage>3.6) { increment--; }
bcm2835_spi_transfern(increment)
char mosi[2]={0b00111111,0b11111100}; // bcm2835_spi_transfern(mosi,2);
bcm2835_spi_transfern(DataIn,2);1111111111110011111111111100 // don't care bits at the beggining and config bits at the end
I assume that you have connected RPI_V2_GPIO_P1_26 to /SYNC
DataIn[0] = 0x00; DataIn[1] = ((uint8_t)(Voltage << 2) & 0xFF); DataIn[2] = ((uint8_t)(Voltage >> 6) & 0xFF); DataIn[3] = 0x00;DataIn[0] = 0b11111100 and DataIn[1] = 0b111111 (that is 0b00111111) should work.uint16_t Voltage=1024 // The digital value
char DataIn[2];
DataIn[0] = ((uint8_t)(Voltage >> 6) & 0xFF);
DataIn[1] = ((uint8_t)(Voltage << 2) & 0xFF);
bcm2835_spi_transfern(DataIn,2);