A2B AD2433 & ADXL317调试总结

文章详细介绍了如何进行A2BAD242x的调试,包括使用ADISDK编译代码,实现I2C和time接口,通过SigmaStudio配置AD2428芯片,以及主从配置和BP/BN信号的检查。在调试过程中遇到的板子上线序问题也进行了提及。

关于A2B AD24xx调试步骤:

  • 编译 ADI 代码:首先需要下载 ADI 提供的 A2B 软件开发工具包(SDK),A2B 软件 SDK 官方下载

  • 文中提到的所有代码和文档都在这款软件的安装路径下。然后按照SDK提供的AE_09_A2B_Stack_UserGuide.pdf文档编写需要的代码的Makefile,并将代码加入到自己驱动中。

  • 必须的函数实现:我们需要实现 I2C 和 time 功能接口。这些接口通常由硬件提供商或芯片制造商提供,然后需要参考 ADI 提供的AE_09_A2B_Stack_UserGuide.pdf文档3.2.1章节,按照说明实现adi_a2b_pal.c中的一些接口,建议复制 a2b-bf 目录下东西作为自己开发基线。

  • SigmaStudio+ 导出配置:SigmaStudio+ 是一款音频处理软件,可以用于对 AD24xx 系列芯片进行配置。在使用 SigmaStudio+ 导出之前,需要先配置 A2B 链路,然后导出生成.c、.h 或者 .xml文件。这些需要参考 SigmaStudio+ 相关文档,按照说明完成。

设备发现流程
在这里插入图片描述

I2S Global Configuration Register

Address: 0x41
在这里插入图片描述

I2S/TDM Port Programming Concepts

Driving Edge ≠ Sampling Edge
Driving Edge ≠ Sampling Edge

Bit SettingData and Clock Format
A2B_I2SGCFG.EARLY = 0SYNC 引脚在数据通道 0 的 MSB(最高有效位)所在的周期内发生变化Early Sync
A2B_I2SGCFG.EARLY = 1早期 SYNC 模式。SYNC 引脚在数据通道 0 的 MSB 前一个周期发生变化
A2B_I2SGCFG.ALT= 0脉冲 SYNC 模式。SYNC 引脚在每个采样周期开始时激活一个 BCLK 周期Sync Mode
A2B_I2SGCFG.ALT= 150% 占空比 SYNC 模式。SYNC 引脚在每个采样周期开始时为高电平,在周期中间为低电平
A2B_I2SGCFG.INV = 0SYNC 信号为高电平有效模式。SYNC 的上升沿对应第一个通道(通道 0)Sync Polarity
A2B_I2SGCFG.INV = 1SYNC 信号为低电平有效模式。SYNC 的下降沿对应第一个通道(通道 0)
A2B_I2SCFG.TXBCLKINV = 0DRX 和 SYNC 引脚在 BCLK 的上升沿采样(Driving Edge)DTXn Change BCLK
A2B_I2SCFG.TXBCLKINV = 1DTX 和 SYNC 引脚在 BCLK 的上升沿发生变化
A2B_I2SCFG.RXBCLKINV = 0DRX 和 SYNC 引脚在 BCLK 的下降沿采样(Sampling Edge)DRXn Sampling BCLK
A2B_I2SCFG.RXBCLKINV = 1DTX 和 SYNC 引脚在 BCLK 的下降沿发生变化

如 “I²S/TDM8 示例时序” 图所示,TDM 通道数据采用 MSB 优先格式(最高有效位在前)。当通过 A²B 总线交换的数据不是恰好 32 位时,收发器会期望输入的 TDM 数据通道以 MSB 优先格式到达,并忽略任何低位数据。

在输出到本地节点时,收发器会将接收到的 A²B 槽位数据以 MSB 优先格式呈现给 I²S/TDM 端口,并将未使用的低位填充为零。例如,如果 A²B 槽位配置为 12 位数据(上行槽位设置 A2B_SLOTFMT.UPSIZE = 1,或下行槽位设置 A2B_SLOTFMT.DNSIZE = 1),则 12 位输入数据必须在 TDM 通道中左对齐,输出数据由 12 位 A²B 槽位数据加上 4 个零位组成。

A²B 收发器支持 SYNC 引脚在通道 0 的 MSB 位所在周期或提前一个周期发生变化。在 早期 SYNC 模式下,SYNC 信号始终提前一个位到达,并可重新相位以匹配数据在 SYNC 信号相关边沿之后一个位到达的情况。

A²B 收发器支持对信号的驱动边沿和采样边沿进行独立设置,可通过 A2B_I2SCFG 寄存器进行配置。

Driving Edge ≠ Sampling Edge 图展示了 I²S/TDM 接口的典型时序,其中输出数据在 BCLK 的一个边沿提供,输入数据在相反的边沿采样(即A2B_I2SCFG.TXBCLKINV ≠ A2B_I2SCFG.RXBCLKINV)

⚠️ 注意: 较高的TDM模式(如TDM16或TDM32)会将位时钟(BCLK)速率提升至可能引发建立时间和保持时间冲突的水平,从而导致I2S/TDM操作异常。对于高TDM速率的情况,需针对TDM接口执行时序分析,同时综合考虑A2B收发器和接口设备的时序要求与开关特性。对于高 TDM 速率,应对 TDM 接口进行时序分析,考虑 A²B 收发器与所连接设备的时序要求和开关特性。有关 A²B 收发器的时序要求和开关特性,请参阅产品数据手册。

在较高的 TDM 模式下,可以通过提前driving edge或延迟sampling edge来获得有效的设置时间余量,因为driving edgesampling edge的设置是完全可配置的。

AD2433(TDM8)

/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x04 (0000 0100), cnt=1
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x02 002, val=0xAD (1010 1101), cnt=3
/dev/i2c-16  read device(0x68) reg=0x03 003, val=0x33 (0011 0011), cnt=3
/dev/i2c-16  read device(0x68) reg=0x04 004, val=0x20 (0010 0000), cnt=3
/dev/i2c-16  read device(0x68) reg=0x5E 094, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x84 (1000 0100), cnt=1
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x80 (1000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x17 023, val=0xFF (1111 1111), cnt=1
Interrupt Source: Master - Interrupt Type: Ignorable interrupt (Code: 255)
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x02 002, val=0xAD (1010 1101), cnt=3
/dev/i2c-16  read device(0x68) reg=0x03 003, val=0x33 (0011 0011), cnt=3
/dev/i2c-16  read device(0x68) reg=0x04 004, val=0x20 (0010 0000), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1B 027, val=0x77 (0111 0111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1C 028, val=0x78 (0111 1000), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1D 029, val=0x0F (0000 1111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x96 150, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x1A 026, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x0F 015, val=0x95 (1001 0101), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x81 (1000 0001), cnt=1
sleep 0x01ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0xA5 165, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x41 065, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x09 009, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x13 019, val=0x95 (1001 0101), cnt=1
sleep 0x64ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x80 (1000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x17 023, val=0x18 (0001 1000), cnt=1
Interrupt Source: Master - Interrupt Type: Ignorable interrupt (Code: 24)
sleep 0x32ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x09 009, val=0x21 (0010 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x69) reg=0x02 002, val=0xAD (1010 1101), cnt=4
/dev/i2c-16  read device(0x69) reg=0x03 003, val=0x28 (0010 1000), cnt=4
/dev/i2c-16  read device(0x69) reg=0x04 004, val=0x01 (0000 0001), cnt=4
/dev/i2c-16  read device(0x69) reg=0x05 005, val=0x01 (0000 0001), cnt=4
/dev/i2c-16 write device(0x69) reg=0x0B 011, val=0x80 (1000 0000), cnt=1
/dev/i2c-16 write device(0x69) reg=0x0C 012, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x69) reg=0x3F 063, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x69) reg=0x41 065, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x69) reg=0x42 066, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x69) reg=0x47 071, val=0x1C (0001 1100), cnt=1
/dev/i2c-16 write device(0x69) reg=0x5D 093, val=0x08 (0000 1000), cnt=1
/dev/i2c-16 write device(0x69) reg=0x65 101, val=0xFF (1111 1111), cnt=1
/dev/i2c-16 write device(0x69) reg=0x96 150, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x69) reg=0x1B 027, val=0x00 (0000 0000), cnt=2
/dev/i2c-16 write device(0x69) reg=0x1C 028, val=0x00 (0000 0000), cnt=2
/dev/i2c-16 write device(0x68) reg=0x09 009, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x0D 013, val=0x08 (0000 1000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x0E 014, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x41 065, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x42 066, val=0x11 (0001 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x1B 027, val=0x77 (0111 0111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1C 028, val=0x78 (0111 1000), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1D 029, val=0x0F (0000 1111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x80 (1000 0000), cnt=1
/dev/i2c-16 write device(0x69) reg=0x40 064, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x10 016, val=0x66 (0110 0110), cnt=1
/dev/i2c-16 write device(0x68) reg=0x11 017, val=0x03 (0000 0011), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x81 (1000 0001), cnt=1
sleep 0x01ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x69) reg=0x09 009, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x82 (1000 0010), cnt=1

AD2433(TDM32)

/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x04 (0000 0100), cnt=1
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x02 002, val=0xAD (1010 1101), cnt=3
/dev/i2c-16  read device(0x68) reg=0x03 003, val=0x33 (0011 0011), cnt=3
/dev/i2c-16  read device(0x68) reg=0x04 004, val=0x20 (0010 0000), cnt=3
/dev/i2c-16  read device(0x68) reg=0x5E 094, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x84 (1000 0100), cnt=1
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x80 (1000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x17 023, val=0xFF (1111 1111), cnt=1
Interrupt Source: Master - Interrupt Type: Ignorable interrupt (Code: 255)
sleep 0x19ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x02 002, val=0xAD (1010 1101), cnt=3
/dev/i2c-16  read device(0x68) reg=0x03 003, val=0x33 (0011 0011), cnt=3
/dev/i2c-16  read device(0x68) reg=0x04 004, val=0x20 (0010 0000), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1B 027, val=0x77 (0111 0111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1C 028, val=0x78 (0111 1000), cnt=3
/dev/i2c-16 write device(0x68) reg=0x1D 029, val=0x0F (0000 1111), cnt=3
/dev/i2c-16 write device(0x68) reg=0x96 150, val=0x02 (0000 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x1A 026, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x0F 015, val=0x77 (0111 0111), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x81 (1000 0001), cnt=1
sleep 0x01ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0xA5 165, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x41 065, val=0x1F (0001 1111), cnt=1
/dev/i2c-16 write device(0x68) reg=0x09 009, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x13 019, val=0x77 (0111 0111), cnt=1
sleep 0x64ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x80 (1000 0000), cnt=1
/dev/i2c-16  read device(0x68) reg=0x17 023, val=0x18 (0001 1000), cnt=1
Interrupt Source: Master - Interrupt Type: Ignorable interrupt (Code: 24)
sleep 0x32ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x09 009, val=0x21 (0010 0001), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x00 (0000 0000), cnt=1
                             ... ...
/dev/i2c-16 write device(0x68) reg=0x10 016, val=0x22 (0010 0010), cnt=1
/dev/i2c-16 write device(0x68) reg=0x11 017, val=0x03 (0000 0011), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x81 (1000 0001), cnt=1
sleep 0x01ms
/dev/i2c-16  read device(0x68) reg=0x16 022, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x01 001, val=0x01 (0000 0001), cnt=1
/dev/i2c-16 write device(0x69) reg=0x09 009, val=0x00 (0000 0000), cnt=1
/dev/i2c-16 write device(0x68) reg=0x12 018, val=0x82 (1000 0010), cnt=1

ADXL317(TDM4 16bit)

i2ctransfer -f -y 16 w2@0x68 0x01 0x00
i2ctransfer -f -y 16 w2@0x69 0x3F 0x00
i2ctransfer -f -y 16 w2@0x69 0x00 0x53
i2ctransfer -f -y 16 w2@0x68 0x01 0x20

i2ctransfer -f -y 16 w2@0x69 0x80 0xBC
i2ctransfer -f -y 16 w2@0x69 0x80 0x43
i2ctransfer -f -y 16 w10@0x69 0x81 0x51 0x05 0x01 0x04 0x4F 0x00 0x4F 0x00 0x4F

如果出现问题检查初始化时主端是否产生BP/BN差分信号(reg=0x09)和48 kHz SYNC信号(reg=0x41),DTX0/DRX0或者SIO0/SIO4是否有波形

遇到的问题
板子上线序问题,BP/BN

写了一个调试脚本解析 adi_a2b_commandlist.xml 配置

#!/usr/bin/env bash

dev=${2:-"16"}
debug() { echo "Running command $((++line_count)): $@"; "$@"; }

grep '<action' "${1:-adi_a2b_commandlist.xml}" | while read -r action; do
    instr=$(echo "${action#*instr=\"}" | cut -d'"' -f1)
    content=$(echo "${action#*\">}" | cut -d'<' -f1 | tr -d '\r')
    [[ $instr == delay ]] && { debug sleep $(bc <<< "scale=3; $((16#${content// /})) / 1000"); continue; }

    addr_width=$(echo "${action#*addr_width=\"}" | cut -d'"' -f1)
    addr=$(printf "%0$((addr_width * 2))X" "$(echo "${action#* addr=\"}" | cut -d'"' -f1)")
    addr_bytes=""; for ((i = 0; i < $addr_width; i++)); do addr_bytes+="\x${addr:$((i * 2)):2}"; done
    len=$(echo "${action#*len=\"}" | cut -d'"' -f1)

    if [[ "${action#*Protocol=\"}" == I2C* ]]; then
        i2caddr=$(printf "0x%02X" "$(echo "${action#*i2caddr=\"}" | cut -d'"' -f1)")
        [[ "$instr" != "read" ]] && { \ 
            debug i2ctransfer -f -y $dev w$len@$i2caddr${addr_bytes//\\x/ 0x} 0x${content// / 0x} || true; } || \
            debug i2ctransfer -f -y $dev w$addr_width@$i2caddr${addr_bytes//\\x/ 0x} r$((len - addr_width))
    else
        spiCmdWidth=$(echo "${action#*SpiCmdWidth=\"}" | cut -d'"' -f1)
        spiCmd=$(printf "%0$((spiCmdWidth * 2))X" "$(echo "${action#*SpiCmd=\"}" | cut -d'"' -f1)")
        spi_cmd_bytes=""; for ((i = 0; i < $spiCmdWidth; i++)); do spi_cmd_bytes+="\x${spiCmd:$((i * 2)):2}"; done
        dummy=""; for ((i=0; i<len-addr_width; i++)); do dummy="${dummy}\\x00"; done
        case "$spiCmd" in
            00|02*|07|C*)
                debug spidev_test -D $dev -s 1000000 -b 8 -v -p $spi_cmd_bytes$addr_bytes${content:+\\x${content// /\\x}} ;;
            01|04)
                debug spidev_test -D $dev -s 1000000 -b 8 -v -p $spi_cmd_bytes$addr_bytes$dummy ;;
            05) 
                debug spidev_test -D $dev -s 1000000 -b 8 -v -p $spi_cmd_bytes$dummy ;;
            *)  
                echo "Unknown spi protocol: $spiCmd" ;;
        esac
    fi  
done

A2B 嵌套
在这里插入图片描述

A2B 回环
请添加图片描述

Bit 4 BUSLOOPBK:A2B_DTX0的数据环回到A2B_DRX0,将A2B_DTX1的数据环回到A2B_DRX1Bit 3/2/1/0位被忽略。

Bit 2 RX2LOOPBK: A2B_DRX0A2B_DRX1引脚上的数据(由 Bit 3 位控制)将被存储到TX帧缓冲区中。A2B_I2SCFGRX0ENRX1ENRX2PINTL位将被忽略

Bit 1 LOOPBK2TX: A2B_DRX0A2B_DRX1引脚上接收到的数据(由 Bit 3 位控制)将通过A2B_DTX0A2B_DTX1引脚发送出去

Bit 0 PATTRN2TX: 启用后,在A2B_DTX0A2B_DTX1引脚的所有通道中发送默认位模式(最多 32 位)。A2B_I2SCFGTX0ENTX1ENTX2PINTL将被忽略。如果 Bit 1 被设置,该位将被忽略

响应周期
在这里插入图片描述

计算响应周期位位置
在这里插入图片描述
例如:如果 A2B_RESPCYCS = 0x5C,即 92(十进制)。代入公式,计算出 SRF 位位置:在这里插入图片描述
响应周期与时钟频率(bit time)
请添加图片描述
计算响应周期时间在这里插入图片描述
如果希望在超帧的第399位生成 SRF,我们可以按照之前的公式来计 A2B_RESPCYCS 和相应的响应周期时间。
在这里插入图片描述
所以,A2B_RESPCYCS 的值应该是 98,即 0x62

延迟范围
在这里插入图片描述
计算总延迟范围

  • 下行延迟(TDDOWN)为 7 ± 2 SYSBCLK,对应范围:
    在这里插入图片描述

  • 上行延迟(TDUP)为 9 ± 2 SYSBCLK,对应范围:
    在这里插入图片描述

对应的位数为

  • 下行延迟:101.7 ns / 20.83 ns ≈ 5 bits 到 183.1 ns / 20.83 ns ≈ 9 bits
  • 上行延迟:142.4 ns / 20.83 ns ≈ 7 bits 到 223.8 ns / 20.83 ns ≈ 11 bits

合作base64:ZGFpeGlhbmc3ODlAaWNsb3VkLmNvbQ==

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值