On a previous revision of the board I was able to use I2C successfully with the '740 chip. We have switched to SPI on the '760 to try to achieve a baud rate of 921600.
I want to rule out that this is not a library issue, however the hardware seems correct. Has anyone had success using the '760 chip with SPI so far? I’ve spent a couple days looking for solutions, or if other people have come across this issue, but have found nothing.
So far I have attempted: resetting the SC16IS760 upon B402 boot, trying multiple baud rates, hard-coding the 14.7456 MHz frequency into the library (int oscillatorHz = 14745600), changing the uint8_t spiClockSpeedMHz value, and some other things.
I tested it with the B Series SoM B402 and the evaluation board with this source code and the library is working for me on SPI1 with your pin definitions.
#include "SC16IS740RK.h"
// Pick a debug level from one of these two:
// SerialLogHandler logHandler;
SerialLogHandler logHandler(LOG_LEVEL_TRACE);
// Pin SC16IS740 Eval Board
// D2 SCK RTS
// D3 MOSI (DI) CTS
// D4 MISO (DO) PWM0
// D5 /RESET PWM1
// D6 /CS PWM2
// Connect TX and RX on the SC16IS740 together (loopback)
SC16IS740SPI extSerial(SPI1, D6);
char out = ' ';
void setup()
{
System.disableFeature(FEATURE_ETHERNET_DETECTION);
waitFor(Serial.isConnected, 10000);
delay(2000);
pinMode(OUTPUT, D5);
digitalWrite(D5, HIGH);
extSerial.begin(9600);
Log.info("reg0=0x%02x", extSerial.readRegister(0));
Log.info("reg1=0x%02x", extSerial.readRegister(1));
}
void loop()
{
while (extSerial.available())
{
int c = extSerial.read();
Log.info("received %d", c);
}
extSerial.print(out);
if (++out >= 127)
{
out = ' ';
}
delay(100);
}
USB serial output:
0000073564 [app] INFO: reg0=0x00
0000073564 [app] INFO: reg1=0x00
...
0000198056 [app] INFO: received 32
0000198157 [app] INFO: received 33
0000198258 [app] INFO: received 34
0000198359 [app] INFO: received 35
0000198460 [app] INFO: received 36
0000198561 [app] INFO: received 37
0000198662 [app] INFO: received 38
0000198763 [app] INFO: received 39
0000198864 [app] INFO: received 40
0000198965 [app] INFO: received 41
Thanks for testing that. Could you share what device OS version you are using? Also just to be sure, this is with the SC16IS740, rather than the '760, correct? I just copy/pasted your code and am still only receiving 0xff.
I can’t think of any differences between the 740 and 760 that would cause this to happen. The data sheet says they are functionally the same.