目录
1. 简介
2. 调试过程
2.1 简要步骤
2.2 Si5338 寄存器配置流程
2.3 AD2的基本配置
2.4 检查Si5338状态
2.5 配置Si5338寄存器
2.6 保存Si5338寄存器
3. 总结
1. 简介
使用Digilent Analog Discovery 2进行调试不仅提升了工作效率,而且极大地简化了常见低速接口的分析过程。在众多低速接口中,I2C接口因其简洁的连接方式和广泛的应用场景而受到特别关注。本文将以I2C接口为例,深入探讨如何利用AD2高效地调试Si5338芯片,一个多用途、任意频率时钟发生器芯片。
I2C接口
I2C(Inter-Integrated Circuit)接口是一种高度灵活的通信协议,通过仅使用两条线(即数据线SDA和时钟线SCL)实现了多个设备间的数据传输。
Si5338芯片
Si5338 可以生成四个独立的时钟信号,每个输出时钟都可以独立配置以支持各种信号格式和供电电压。这使得它非常适合在有限空间内实现多频率合成。Si5338 具有极低的抖动性能。它广泛应用于网络、通讯、高性能计算等领域,特别是在需要精确时钟信号的场合。Si5338通过I2C接口进行配置和控制,可以灵活地设置输出频率、相位和其他参数,满足不同应用的需求。
2. 调试过程
2.1 简要步骤
连接设备:首先,将AD2的逻辑分析仪通道连接到Si5338芯片的I2C接口上,确保SDA和SCL线分别对应。可以利用AD2提供的电源功能给Si5338供电。
配置WaveForms软件:启动AD2随附的WaveForms软件,并配置逻辑分析仪工具以适应I2C协议的特定参数,如时钟速度等。WaveForms软件能够自动识别并解码I2C通信,大大简化了调试过程。
捕获和分析数据:在Si5338进行通信时,使用AD2捕获I2C总线上的数据。通过WaveForms软件,可以实时查看和分析数据传输过程,包括启动条件、地址帧、数据帧和停止条件等。
调试和优化:根据捕获的数据,可以对Si5338的配置进行调整和优化。如果发现通信错误或性能不佳的问题,可以通过分析I2C总线上的数据来定位问题源头,并进行相应的调整。
调试中的注意事项:
- 确保AD2与Si5338之间的连接稳定可靠,避免在数据传输过程中出现干扰或误操作。
- 注意观察I2C总线的电气特性,如上拉电阻的配置,以确保通信的稳定性和可靠性。
2.2 Si5338 寄存器配置流程
了解 Si5338 寄存器配置流程是接下来使用AD2进行调试的基础。
2.3 AD2的基本配置
需要开启两个功能模块:
- Protocol,用于开启AD2的IIC物理层
- Script,用于编写Javascript脚本,实现上一节所描述Si5338配置流程
2.4 检查Si5338状态
//Check Si5338 Status
clear();
print("start\n");
if (Protocol.I2C.Clear() != true) throw "I2C bus error. Check the pull-ups.";
var dev_addr = 0x70;
var reg_addr = 218;
var reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
if ((reg_data & 0x10) == 0)
print("PLL_LOL = 0, PLL is locked.\n");
else
print("PLL_LOL = 1, PLL is loss of locked.\n");
if ((reg_data & 0x08) == 0)
print("LOS_FDBK = 0, Present of Signal Feedback Input.\n");
else
print("LOS_FDBK = 1, Loss Of Signal Feedback Input.\n");
if ((reg_data & 0x04) == 0)
print("LOS_CLKIN = 0, Present of Signal Clock Input.\n");
else
print("LOS_CLKIN = 1, Loss Of Signal Clock Input.\n");
if ((reg_data & 0x01) == 0)
print("SYS_CAL = 0, PLL is in process of acquiring lock.\n");
else
print("SYS_CAL = 1, PLL is not acquiring lock.\n");
print("end");
2.5 配置Si5338寄存器
//C0 - 125MHz, lvds
//C1 - 160MHz, lvds
//C2 - 100MHz, lvds
//C3 - 50MHz, lvds
clear();
print("start");
if (Protocol.I2C.Clear() != true) throw "I2C bus error. Check the pull-ups.";
var dev_addr = 0x71;
var reg_addr = 0 ;
var reg_data = 0 ;
var reg_data_t = 0 ;
var curr = new Array(3);
var reg_store = [
[ 0,0x00,0x00],
[ 1,0x00,0x00],
[ 2,0x00,0x00],
[ 3,0x00,0x00],
[ 4,0x00,0x00],
[ 5,0x00,0x00],
[ 6,0x08,0x1D],
[ 7,0x00,0x00],
[ 8,0x70,0x00],
[ 9,0x0F,0x00],
[ 10,0x00,0x00],
[ 11,0x00,0x00],
[ 12,0x00,0x00],
[ 13,0x00,0x00],
[ 14,0x00,0x00],
[ 15,0x00,0x00],
[ 16,0x00,0x00],
[ 17,0x00,0x00],
[ 18,0x00,0x00],
[ 19,0x00,0x00],
[ 20,0x00,0x00],
[ 21,0x00,0x00],
[ 22,0x00,0x00],
[ 23,0x00,0x00],
[ 24,0x00,0x00],
[ 25,0x00,0x00],
[ 26,0x00,0x00],
[ 27,0x71,0x80],
[ 28,0x15,0xFF],
[ 29,0x90,0xFF],
[ 30,0xB0,0xFF],
[ 31,0xC0,0xFF],
[ 32,0xC0,0xFF],
[ 33,0xC0,0xFF],
[ 34,0xC0,0xFF],
[ 35,0xAA,0xFF],
[ 36,0x06,0x1F],
[ 37,0x06,0x1F],
[ 38,0x06,0x1F],
[ 39,0x06,0x1F],
[ 40,0x84,0xFF],
[ 41,0x10,0x7F],
[ 42,0x24,0x3F],
[ 43,0x00,0x00],
[ 44,0x00,0x00],
[ 45,0x00,0xFF],
[ 46,0x00,0xFF],
[ 47,0x14,0x3F],
[ 48,0x2A,0xFF],
[ 49,0x05,0xFF],
[ 50,0xC4,0xFF],
[ 51,0x07,0xFF],
[ 52,0x10,0xFF],
[ 53,0x00,0xFF],
[ 54,0x08,0xFF],
[ 55,0x00,0xFF],
[ 56,0x00,0xFF],
[ 57,0x00,0xFF],
[ 58,0x00,0xFF],
[ 59,0x01,0xFF],
[ 60,0x00,0xFF],
[ 61,0x00,0xFF],
[ 62,0x00,0x3F],
[ 63,0x10,0xFF],
[ 64,0xD0,0xFF],
[ 65,0x05,0xFF],
[ 66,0x00,0xFF],
[ 67,0x00,0xFF],
[ 68,0x00,0xFF],
[ 69,0x00,0xFF],
[ 70,0x08,0xFF],
[ 71,0x00,0xFF],
[ 72,0x00,0xFF],
[ 73,0x00,0x3F],
[ 74,0x10,0xFF],
[ 75,0x80,0xFF],
[ 76,0x0A,0xFF],
[ 77,0x00,0xFF],
[ 78,0x00,0xFF],
[ 79,0x00,0xFF],
[ 80,0x00,0xFF],
[ 81,0x01,0xFF],
[ 82,0x00,0xFF],
[ 83,0x00,0xFF],
[ 84,0x00,0x3F],
[ 85,0x10,0xFF],
[ 86,0x00,0xFF],
[ 87,0x17,0xFF],
[ 88,0x00,0xFF],
[ 89,0x00,0xFF],
[ 90,0x00,0xFF],
[ 91,0x00,0xFF],
[ 92,0x01,0xFF],
[ 93,0x00,0xFF],
[ 94,0x00,0xFF],
[ 95,0x00,0x3F],
[ 96,0x10,0x00],
[ 97,0x2A,0xFF],
[ 98,0x66,0xFF],
[ 99,0x08,0xFF],
[100,0x00,0xFF],
[101,0x00,0xFF],
[102,0x00,0xFF],
[103,0x03,0xFF],
[104,0x00,0xFF],
[105,0x00,0xFF],
[106,0x80,0xBF],
[107,0x00,0xFF],
[108,0x00,0xFF],
[109,0x00,0xFF],
[110,0x80,0xFF],
[111,0x00,0xFF],
[112,0x00,0xFF],
[113,0x00,0xFF],
[114,0x80,0xFF],
[115,0x00,0xFF],
[116,0x80,0xFF],
[117,0x00,0xFF],
[118,0x80,0xFF],
[119,0x00,0xFF],
[120,0x00,0xFF],
[121,0x00,0xFF],
[122,0x80,0xFF],
[123,0x00,0xFF],
[124,0x00,0xFF],
[125,0x00,0xFF],
[126,0x00,0xFF],
[127,0x00,0xFF],
[128,0x00,0xFF],
[129,0x00,0x0F],
[130,0x00,0x0F],
[131,0x00,0xFF],
[132,0x00,0xFF],
[133,0x00,0xFF],
[134,0x00,0xFF],
[135,0x00,0xFF],
[136,0x00,0xFF],
[137,0x00,0xFF],
[138,0x00,0xFF],
[139,0x00,0xFF],
[140,0x00,0xFF],
[141,0x00,0xFF],
[142,0x00,0xFF],
[143,0x00,0xFF],
[144,0x00,0xFF],
[145,0x00,0x00],
[146,0xFF,0x00],
[147,0x00,0x00],
[148,0x00,0x00],
[149,0x00,0x00],
[150,0x00,0x00],
[151,0x00,0x00],
[152,0x00,0xFF],
[153,0x00,0xFF],
[154,0x00,0xFF],
[155,0x00,0xFF],
[156,0x00,0xFF],
[157,0x00,0xFF],
[158,0x00,0x0F],
[159,0x00,0x0F],
[160,0x00,0xFF],
[161,0x00,0xFF],
[162,0x00,0xFF],
[163,0x00,0xFF],
[164,0x00,0xFF],
[165,0x00,0xFF],
[166,0x00,0xFF],
[167,0x00,0xFF],
[168,0x00,0xFF],
[169,0x00,0xFF],
[170,0x00,0xFF],
[171,0x00,0xFF],
[172,0x00,0xFF],
[173,0x00,0xFF],
[174,0x00,0xFF],
[175,0x00,0xFF],
[176,0x00,0xFF],
[177,0x00,0xFF],
[178,0x00,0xFF],
[179,0x00,0xFF],
[180,0x00,0xFF],
[181,0x00,0x0F],
[182,0x00,0xFF],
[183,0x00,0xFF],
[184,0x00,0xFF],
[185,0x00,0xFF],
[186,0x00,0xFF],
[187,0x00,0xFF],
[188,0x00,0xFF],
[189,0x00,0xFF],
[190,0x00,0xFF],
[191,0x00,0xFF],
[192,0x00,0xFF],
[193,0x00,0xFF],
[194,0x00,0xFF],
[195,0x00,0xFF],
[196,0x00,0xFF],
[197,0x00,0xFF],
[198,0x00,0xFF],
[199,0x00,0xFF],
[200,0x00,0xFF],
[201,0x00,0xFF],
[202,0x00,0xFF],
[203,0x00,0x0F],
[204,0x00,0xFF],
[205,0x00,0xFF],
[206,0x00,0xFF],
[207,0x00,0xFF],
[208,0x00,0xFF],
[209,0x00,0xFF],
[210,0x00,0xFF],
[211,0x00,0xFF],
[212,0x00,0xFF],
[213,0x00,0xFF],
[214,0x00,0xFF],
[215,0x00,0xFF],
[216,0x00,0xFF],
[217,0x00,0xFF],
[218,0x00,0x00],
[219,0x00,0x00],
[220,0x00,0x00],
[221,0x0D,0x00],
[222,0x00,0x00],
[223,0x00,0x00],
[224,0xF4,0x00],
[225,0xF0,0x00],
[226,0x00,0x00],
[227,0x00,0x00],
[228,0x00,0x00],
[229,0x00,0x00],
[231,0x00,0x00],
[232,0x00,0x00],
[233,0x00,0x00],
[234,0x00,0x00],
[235,0x00,0x00],
[236,0x00,0x00],
[237,0x00,0x00],
[238,0x14,0x00],
[239,0x00,0x00],
[240,0x00,0x00],
[242,0x02,0x02],
[243,0xF0,0x00],
[244,0x00,0x00],
[245,0x00,0x00],
[247,0x00,0x00],
[248,0x00,0x00],
[249,0xA8,0x00],
[250,0x00,0x00],
[251,0x84,0x00],
[252,0x00,0x00],
[253,0x00,0x00],
[254,0x00,0x00],
[255, 1, 0xFF], // set page bit to 1
[ 0,0x00,0x00],
[ 1,0x00,0x00],
[ 2,0x00,0x00],
[ 3,0x00,0x00],
[ 4,0x00,0x00],
[ 5,0x00,0x00],
[ 6,0x00,0x00],
[ 7,0x00,0x00],
[ 8,0x00,0x00],
[ 9,0x00,0x00],
[ 10,0x00,0x00],
[ 11,0x00,0x00],
[ 12,0x00,0x00],
[ 13,0x00,0x00],
[ 14,0x00,0x00],
[ 15,0x00,0x00],
[ 16,0x00,0x00],
[ 17,0x01,0x00],
[ 18,0x00,0x00],
[ 19,0x00,0x00],
[ 20,0x90,0x00],
[ 21,0x31,0x00],
[ 22,0x00,0x00],
[ 23,0x00,0x00],
[ 24,0x01,0x00],
[ 25,0x00,0x00],
[ 26,0x00,0x00],
[ 27,0x00,0x00],
[ 28,0x00,0x00],
[ 29,0x00,0x00],
[ 30,0x00,0x00],
[ 31,0x00,0xFF],
[ 32,0x00,0xFF],
[ 33,0x01,0xFF],
[ 34,0x00,0xFF],
[ 35,0x00,0xFF],
[ 36,0x90,0xFF],
[ 37,0x31,0xFF],
[ 38,0x00,0xFF],
[ 39,0x00,0xFF],
[ 40,0x01,0xFF],
[ 41,0x00,0xFF],
[ 42,0x00,0xFF],
[ 43,0x00,0x0F],
[ 44,0x00,0x00],
[ 45,0x00,0x00],
[ 46,0x00,0x00],
[ 47,0x00,0xFF],
[ 48,0x00,0xFF],
[ 49,0x01,0xFF],
[ 50,0x00,0xFF],
[ 51,0x00,0xFF],
[ 52,0x90,0xFF],
[ 53,0x31,0xFF],
[ 54,0x00,0xFF],
[ 55,0x00,0xFF],
[ 56,0x01,0xFF],
[ 57,0x00,0xFF],
[ 58,0x00,0xFF],
[ 59,0x00,0x0F],
[ 60,0x00,0x00],
[ 61,0x00,0x00],
[ 62,0x00,0x00],
[ 63,0x00,0xFF],
[ 64,0x00,0xFF],
[ 65,0x01,0xFF],
[ 66,0x00,0xFF],
[ 67,0x00,0xFF],
[ 68,0x90,0xFF],
[ 69,0x31,0xFF],
[ 70,0x00,0xFF],
[ 71,0x00,0xFF],
[ 72,0x01,0xFF],
[ 73,0x00,0xFF],
[ 74,0x00,0xFF],
[ 75,0x00,0x0F],
[ 76,0x00,0x00],
[ 77,0x00,0x00],
[ 78,0x00,0x00],
[ 79,0x00,0xFF],
[ 80,0x00,0xFF],
[ 81,0x00,0xFF],
[ 82,0x00,0xFF],
[ 83,0x00,0xFF],
[ 84,0x90,0xFF],
[ 85,0x31,0xFF],
[ 86,0x00,0xFF],
[ 87,0x00,0xFF],
[ 88,0x01,0xFF],
[ 89,0x00,0xFF],
[ 90,0x00,0xFF],
[ 91,0x00,0x0F],
[ 92,0x00,0x00],
[ 93,0x00,0x00],
[ 94,0x00,0x00],
[255, 0, 0xFF] ]; // set page bit to 0
//End of file
//Disable all outputs; Set OEB_ALL = 1; reg230[4];
print("Disable all outputs");
reg_addr = 230;
reg_data = 0x10;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Pause LOL; Set DIS_LOL = 1; reg241[7];
print("Pause PLL loss of lock detect.");
reg_addr = 241;
reg_data = 0xE5;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Write register map;
print("Writing register map.");
for (var i = 0; i < 350-1; i++) {
curr = reg_store[i];
if (curr[2] != 0x00) {
//do a read-modify-write
reg_addr = curr[0];
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]); // read current value
reg_data = reg_data & ~curr[2]; //clear current value
reg_data = reg_data | (curr[1] & curr[2]); //set new value
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
}
}
// check LOS alarm for the xtal input
// on IN1 and IN2 (and IN3 if necessary)
reg_addr = 218;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & 0x04;
while (reg_data != 0) {
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & 0x04;
}
print("Xtal input exists.");
//FCAL_OVRD_EN = 0
print("Disable override Frequency Calibration.");
reg_addr = 49;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & 0x7F;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Soft reset
print("Soft reset");
reg_addr = 246;
reg_data = 0x02;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//DIS_LOL = 0
print("Continue PLL loss of lock detect");
reg_addr = 241;
reg_data = 0x65;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Wait 25ms
wait(0.025);
//Make sure the device locked by checking PLL_LOL and SYS_CAL
reg_addr = 218;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & 0x15;
while (reg_data != 0) {
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & 0x15;
}
print("PLL is locked and acquiring lock completed");
//Copy FCAL value to active registers
print("Copy FCAL value to active registers");
reg_addr = 235;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_addr = 45;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
reg_addr = 236;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_addr = 46;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
reg_addr = 237;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_addr = 47;
reg_data_t = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = (reg_data & 3) | (reg_data_t & 0xFC);
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Set PLL to FCAL values; Set FCAL_OVRD_EN = 1; reg49[7];
print("Set PLL to FCAL values, override Frequency Calibration for the VCO");
reg_addr = 49;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data | 0x80;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
//Enable Outputs; Set OEB_ALL = 0; reg 230[4];
print("Enable Outputs");
reg_addr = 230;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
reg_data = reg_data & ~0x10;
Protocol.I2C.Write(dev_addr, [ reg_addr, reg_data ]);
reg_addr = 218;
reg_data = Protocol.I2C.Read(dev_addr, 1, [reg_addr]);
if ((reg_data & 0x10) == 0) {
print("\n***PLL_LOL = 0, PLL is locked.***\n");
print("***Config Si5338 Success.***");
}
print("end");
2.6 保存Si5338寄存器
//遍历Si5338寄存器,并存储到指定txt文件
clear();
print("start");
if (Protocol.I2C.Clear() != true) throw "I2C bus error. Check the pull-ups.";
const rom_len = 350;
var filepath = "D:/Si5338/tt.txt";
var data = new Array(rom_len);
var addr = 0;
FileWrite(filepath, ""); //Clear all exist content
Protocol.I2C.Write(0x70, [ 255, 0 ]);
for(addr = 0; addr < 255; addr++) {
data[addr] = Protocol.I2C.Read(0x70, 1, [addr]);
FileAppendLine(filepath, addr + "," + data[addr]);
print(addr, data[addr]);
}
Protocol.I2C.Write(0x70, [ 255, 1 ]);
for(addr = 0; addr < rom_len - 255; addr++) {
data[addr] = Protocol.I2C.Read(0x70, 1, [addr]);
FileAppendLine(filepath, (255+addr) + "," + data[addr]);
print(255+addr, data[addr]);
}
print("end");
3. 总结
通过上述步骤和注意事项,使用Digilent AD2调试Si5338芯片或其他基于I2C接口的设备将变得简单高效。AD2不仅提供了强大的捕获和分析能力,而且通过其直观的用户界面和丰富的功能,极大地降低了调试低速接口的难度,提高了开发效率。无论是学生、爱好者还是专业工程师,AD2都是进行电子设计和调试的理想工具。