As promised attached is the schematic showing the connection between the RMB20SC encoder and the components needed to interface it with teensie 3.6. PA5 is the sck connected to (pin13 of the teensie board) PA4 and PA5 are the ss for my two encoders (pin 24,25 of the teensie board) and PA6 is the MISO (pin 13 of teensie). The encoders and components U7 and U8 are power by an external 5V supply. Clock signals of enc1 are connected at pins 14,11 of U7 receiver and for my second encoder at pins 10 and 13 of U7. Data signals are connected at pins 2 and 1 and pins 6 and 7 of U7 driver. Below is the sketch that I am using to generate the clock signal. To check MISO independent i just input a 3.3 V at MISO (pin 13) if I have uint8_t mybyte; I receive 255 as an output of my serial port, however when I change uint16_t mybyte; I still receive 255 shouldn't I receive 65535 is something wrong with the library or do I miss something code wise. I am trying to check that everything is working properly before I try to change the CTAR register of the SPI library to make it possible to read 13 bits. Thank you so far for the effort.
Code:
#include <SPI.h> // include the SPI library:
const int ssimu = 10;
const int sshand = 24;
const int ssfork = 25;
const int pwrencoders = 26;
void setup() {
// set the slaveSelectPin as an output:
pinMode (ssimu, OUTPUT);
pinMode (sshand, OUTPUT);
pinMode (ssfork, OUTPUT);
pinMode (pwrencoders, OUTPUT);
// initialize SPI:
SPI.begin();
Serial.begin(500000);
}
void loop() {
digitalWrite(ssimu,HIGH);
digitalWrite(sshand,HIGH);
digitalWrite(pwrencoders,LOW);
digitalWrite(ssfork,LOW);
SPI.beginTransaction(SPISettings(125000, MSBFIRST, SPI_MODE0));
uint8_t mybyte;
mybyte = SPI.transfer(0);
Serial.print("Fork(deg)");
Serial.println(mybyte);
}