Giter VIP home page Giter VIP logo

sc16is752's Introduction

SC16IS752

SC16IS752 Driver for ATmega328/ESP8266
SC16IS750/752 Driver for RaspberryPi

SC16IS752-2

SC16IS752-1


for i2c

SC16IS750/752 ATmega328/ESP8266 RPi
VCC -- 5V(*1) 5V(*1)
GND -- GND GND
RESET -- N/C N/C
A0/CS -- 5V(*2) 5V(*2)
A1/SI -- 5V(*2) 5V(*2)
NC/SO -- N/C N/C
IRQ -- N/C N/C
I2C/SPI -- 5V 5V
SCL/SCLK -- SCL(*3) SCL(*4)
SDA/VSS -- SDA(*3) SDA(*4)

(*1) The SC16IS750 breakout board is equipped with a MIC5219 LG33 voltage regulator, which provides 3.3V to the chip.
The SC16IS752 breakout board is equipped with a AMS1117-3.3 voltage regulator, which provides 3.3V to the chip.
Therefore, the level of i2c is 3.3V, but all pins are 5V tolerant.
It can be used with either 3.3V MPU or 5V MPU.

(*2)i2c address selection

A0 A1 Address
5V 5V 0x48
5V GND 0x49
GND 5V 0x4C
GND GND 0x4D

(*3)Requires PullUp
How to change scl/sda.
#13

(*4)No Requires PullUp


for SPI

SC16IS750/752 ATmega328/ESP8266/Rpi
VCC -- 5V(*1)
GND -- GND
RESET -- N/C
A0/CS -- CS
A1/SI -- MOSI
NC/SO -- MISO
IRQ -- N/C
I2C/SPI -- GND
SCL/SCLK -- SCK
SDA/VSS -- GND

(*1) The SC16IS750 breakout board is equipped with a MIC5219 LG33 voltage regulator, which provides 3.3V to the chip.
The SC16IS752 breakout board is equipped with a AMS1117-3.3 voltage regulator, which provides 3.3V to the chip.
Therefore, the level of SPI is 3.3V, but all pins are 5V tolerant.
It can be used with either 3.3V MPU or 5V MPU.

Baudrate generator

SC16IS750/752 has baudrate generator.
Since the communication speed is caluculated by dividing the frequency of the crystal, an error may occur depending on the communication speed.
How to divide is described in the data sheet.
For example, if you use a 3.072MHz crystal and set the communication speed to 3600bps, you need to divide the crystal frequency by 53.3333.
Since such a value cannot be set in the register, sets 54 in the register.
As a result, the actual communication speed will be 3555bps.
This calculation can be calculated with the following code.

#include <stdio.h>
void main() {
  long crystal_freq = 3072000; // 3,072,000MHz
  long prescaler = 1;
  long baudrate = 3600;
  long divisor1 = crystal_freq/prescaler;
  long divisor2 = baudrate*16;
  double divisorf = (double)divisor1/(double)divisor2;
  long divisor = divisorf + 0.999;
  printf("divisor1=%ld divisor2=%ld divisor=%ld divisorf=%f\n",
    divisor1, divisor2, divisor, divisorf);

  long actual_baudrate = (divisor1/divisor)/16;
  printf("actual_baudrate=%ld\n", actual_baudrate);
}

sc16is752's People

Contributors

nopnop2002 avatar rary21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sc16is752's Issues

I2c address 0x4D

Hello! I have the same module. The I2c scanner transmits the address 0x4D. And the example with 0x4D does not work. Do not know what the problem is?

How to specifying SCL and SDA.

  • arduino core for esp32:
    Wire.setPins(int sdaPin, int sclPin);
    i2cuart.begin(baudrate_A, baudrate_B);

  • arduino core for esp8266:
    Can not.

  • atmega:
    #define SDA_PORT PORTD
    #define SDA_PIN SDA
    #define SCL_PORT PORTD
    #define SCL_PIN SCL
    #include <SoftI2CMaster.h>
    #include <SoftWire.h>
    SoftWire Wire = SoftWire();
    i2cuart.begin(baudrate_A, baudrate_B);

  • Arduino core support for STM32 based boards:
    Wire.setSCL(SCL);
    Wire.setSDA(SDA);
    i2cuart.begin(baudrate_A, baudrate_B);

  • Arduino Core for Nordic Semiconductor nRF5 based boards:
    Wire.setPins(int sdaPin, int sclPin);
    i2cuart.begin(baudrate_A, baudrate_B);

question about this driver

is it possible to register this to the OS as /dev/tty-something device so it can be used with ready made apps ?

RS485 ESP32 half-duplex communication

Hi, I have a question, so I have two identical devices that I would like to communicate via RX / TX (RS485). Both devices are exactly the same component, but as far as I know this is half-duplex mode, which means the first device sends, the second device receives and then again the second device receives and the first device sends. I have no idea how to write code for this communication. I found here as far as this chip is concerned GitHub - nopnop2002/SC16IS752: Driver for SC16IS752 also tried to load on both devices example code SC16IS752/Arduino & ESP8266/example/I2C_RECEIVE at master · nopnop2002/SC16IS752 · GitHub but nothing works. Some ideas?

no Default SDA Pin for Second Peripheral

Hello,

I'm using the arduino version (nonop2002/sc16s752) with arduino core esp 32 as component (esp-idf 4.4, arduino esp32 master)
The program compilation is OK, but at run time, when it arrives at :

i2cuart.begin(SC16IS752_DEFAULT_SPEED, SC16IS752_DEFAULT_SPEED);

Those errors appears and the esp32 reboot :

[ 56][E][Wire.cpp:77] initPins(): no Default SDA Pin for Second Peripheral
[ 57][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 59][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 65][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 72][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 78][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 85][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 91][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 98][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 105][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 111][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 117][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 123][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 129][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 136][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 143][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 149][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 155][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 161][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 167][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 174][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 180][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
[ 187][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 193][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
[ 199][E][esp32-hal-i2c.c:225] i2cWriteReadNonStop(): could not acquire lock
E (734) Main: I2C_serial not found

Any idea if it's coming from me or from the library ?

Thanks, Ed.

Using interrupts on digital pins

Hi,
Can someone explain me how to use interrupts in this expander? I would like to detect changes on digital pins. Does the expander store pin number by which the interrupt was trigerred or do I need to read all the pins and define which pin trigerred the interrupt by myself in Arduino code?

Question on wiring

Hi,
My sensor is i2c and i want to convert it to rs485 so that it can connect with my controllers at 20 meter away. But I do not want to use any MCU to convert i2c to RS485.

So I want to connect my i2c sensor to this SC16IS752 and then to UART~RS485(MAX485) module and then to my controller. Does this work?

Thanks

RTC with UART, bus busy

If I'm using RTC (PCF8523) which uses I2C also as UART(SC16IS752) I keep getting error (if using each component separately it works as it should):

10:14:26.202 -> [D][esp32-hal-i2c.c:1345] i2cProcQueue(): Gross Timeout Dead start=0x28cf0, end=0x28d22, =50, max=50 error=1
10:14:26.202 -> [E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbec1c
10:14:26.202 -> [I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60027000 date=0x16042000
10:14:26.202 -> [I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8568
10:14:26.202 -> [I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=1
10:14:26.202 -> [I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1
10:14:26.237 -> [I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3
10:14:26.237 -> [I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1
10:14:26.237 -> [I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8600 bits=200
10:14:26.237 -> [I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb8630
10:14:26.237 -> [I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffb864c
10:14:26.237 -> [I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=2
10:14:26.237 -> [I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=1
10:14:26.237 -> [I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=-1
10:14:26.274 -> [I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=1
10:14:26.274 -> [I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000
10:14:26.274 -> [I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled
10:14:26.274 -> [I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled
10:14:26.274 -> [I][esp32-hal-i2c.c:1130] i2cProcQueue(): Bus busy, reinit

My code.
`
#include <SPI.h>
#include <Wire.h>
#include <SC16IS752.h>

#define GPIO 0
#define EXP_PIN 21
#include "RTClib.h"

RTC_PCF8523 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

SC16IS752 i2cuart = SC16IS752(SC16IS750_PROTOCOL_I2C, 0x48);

void setup()
{
Serial.begin(115200);
Serial.println("Start testing");

pinMode(EXP_PIN, OUTPUT);
digitalWrite(EXP_PIN, HIGH);

if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
rtc.start();

i2cuart.begin(SC16IS752_DEFAULT_SPEED, SC16IS752_DEFAULT_SPEED); //baudrate setting
if (i2cuart.ping() != 1) {
Serial.println("Device not found");
while (1);
} else {
Serial.println("Device found");
}

i2cuart.pinMode(GPIO, OUTPUT);
i2cuart.digitalWrite(GPIO, LOW);
}

void loop()
{
i2cuart.digitalWrite(GPIO, HIGH);
delay(1000);
i2cuart.digitalWrite(GPIO, LOW);
delay(1000);

DateTime now = rtc.now();
Serial.print(now.year(), DEC);

delay(5000);
}
`

Add LICENSE

I'd like to use this library but this repository does not include LICENSE.
Would it be possible to clarify the license terms?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.