Hello,
Can anyone tell me if the Write function (used in WaveForms I2C Custom Script) generates a stop bit?
Here is my script.
The first Write, writes a value to a register.
The 2nd Write is actually setting up for reading the register. I need to know if this command is sending a stop bit or not.
// Simple test to read and write register using I2C
const adr = 0x64; // address of device
if(Clear()!=true) return "I2C bus error. Check the pull-ups.";
if(Write(adr)!=true) return "Device NAK";
Write(adr, 0x40, 0x00, 0xC0, 0x0E, 0x06); // Write the value 6 to register 0x4000C00E
Write(adr, 0x40, 0x00, 0xC0, 0x0E); // Send a write without data because we need to read this register
wait(0.1);
var rg = Read(adr, 1); // Read 1 byte from device
return rg;
This script appears to work, as rg ends up having the value 0X6. But I need to know if a Stop bit is sent after that 2nd read. If one is sent, this tells me my device under test will work with a Stop bit in between the write and the read. I was told I need to read register on my DUT like this (notice no Stop bit in between the Write and the Read), which is why I'm asking:
Read:
| S | I2C ADDR R/W=0 | AS | REGADDR BYTE 4 | AS | REGADDR BYTE 3 | AS | REGADDR BYTE 2 | AS | REGADDR BYTE 1 | AS | S | I2C ADDR R/W=1 | AS | DATA BYTE 1 | AM | DATA BYTE 2 | AM | DATA BYTE 3 | AM |.. | DATA BYTE N | P |
Where:
S is the start bit
P is the stop bit
AM is acknowledge by master
AS is acknowledge by slave
Question
wolfie
Hello,
Can anyone tell me if the Write function (used in WaveForms I2C Custom Script) generates a stop bit?
Here is my script.
The first Write, writes a value to a register.
The 2nd Write is actually setting up for reading the register. I need to know if this command is sending a stop bit or not.
// Simple test to read and write register using I2C
const adr = 0x64; // address of device
if(Clear()!=true) return "I2C bus error. Check the pull-ups.";
if(Write(adr)!=true) return "Device NAK";
Write(adr, 0x40, 0x00, 0xC0, 0x0E, 0x06); // Write the value 6 to register 0x4000C00E
Write(adr, 0x40, 0x00, 0xC0, 0x0E); // Send a write without data because we need to read this register
wait(0.1);
var rg = Read(adr, 1); // Read 1 byte from device
return rg;
This script appears to work, as rg ends up having the value 0X6. But I need to know if a Stop bit is sent after that 2nd read. If one is sent, this tells me my device under test will work with a Stop bit in between the write and the read. I was told I need to read register on my DUT like this (notice no Stop bit in between the Write and the Read), which is why I'm asking:
Read:
| S | I2C ADDR R/W=0 | AS | REGADDR BYTE 4 | AS | REGADDR BYTE 3 | AS | REGADDR BYTE 2 | AS | REGADDR BYTE 1 | AS | S | I2C ADDR R/W=1 | AS | DATA BYTE 1 | AM | DATA BYTE 2 | AM | DATA BYTE 3 | AM |.. | DATA BYTE N | P |
Where:
Edited by wolfieS is the start bit
P is the stop bit
AM is acknowledge by master
AS is acknowledge by slave
Thanks!
Rob
Copy and pasted wrong info
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now