Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Easy way to test/debug/drive I2C and SPI (Step-by-step tutorial) (With screenshots) (Open source)

Status
Not open for further replies.

liuzhiyong

Newbie
Newbie level 1
Joined
May 19, 2023
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
24
Required Hardware
This is tested on Arduino Uno R3, but it should work on other Arduino types, if the API is compatible. (Only Arduino functions are used, no fancy stuff of registers. It should be compatible)

Required Software
Get the source code with GitHub link at:
https://signaloperator.com/

Example #1 - Drive "at24c01" with I2C
i2cscan (Scan for I2C slave devices, 50 is AT24C01)
i2cwrite @50 00 nostop (Address 00)
i2cread @50 04 stop (Read 04 bytes)
i2cwrite @50 00 F0 F1 F2 F3 stop (Write F0 F1 F2 F3 to address 00)
i2cwrite @50 01 AA BB stop (Write AA BB to address 01)
i2cwrite @50 00 nostop (Address 00)
i2cread @50 04 stop (Read 04 bytes)

We read four bytes in the end, which shows two operations of writing are both done. Here is the screenshot:
tutorial-1-i2c-at24c01.png


Example #2 - Drive "lm75a" with I2C
i2cscan (Scan for I2C slave devices, 48 is LM75A)
i2cwrite @48 00 nostop (Address 00, Temperature)
i2cread @48 02 stop (Two bytes of data)

We read data in the end, and it's "(0x1360>>7)*0.5 = 19°C". Here is the screenshot:
tutorial-2-i2c-lm75a.png


Example #3 - Drive "w25q128" with SPI
spi @0AM0 03 00 00 00 FF FF FF FF (Read 4 bytes from address 00 00 00)
spi @0AM0 06 (Enable writing)
spi @0AM0 02 00 00 00 11 22 33 44 (Write 4 bytes to address 00 00 00)
spi @0AM0 03 00 00 00 FF FF FF FF (Read 4 bytes from address 00 00 00)

We read four bytes in the end, which shows the writing operation is done. Here is the screenshot:
tutorial-3-spi-w25q128.png


More Details
The text editor in these screenshots contains detailed explanation(for example, how to use another SPI mode). And the source code, one nice "ino" file, contains tons of comment explaining everything in great detail.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top