TI中文支持网
TI专业的中文技术问题搜集分享网站

STM32F28027 I2C配置为从机,没有应答信号

下面是I2C作为从机的初始化:主机对从机操作,从机没有应答

// Step1: Config Own Address (work as a slave device)
I2caRegs.I2COAR = 0x0050;

// Step2: Config Module Clock
// I2CCLK = SYSCLK/(I2CPSC+1)
#if (CPU_FRQ_40MHZ||CPU_FRQ_50MHZ)
I2caRegs.I2CPSC.all = 4; // Prescaler – need 7-12 Mhz on module clk
#endif

#if (CPU_FRQ_60MHZ)
I2caRegs.I2CPSC.all = 6; // Prescaler – need 7-12 Mhz on module clk
#endif

// Step3: Config I2C Bus SCLK clock

// Step4: Config I2C Interrupt Source
// Reference: User Guide Page26; Enable = 1, Disable = 0
I2caRegs.I2CIER.bit.AAS = 1; // Addressed as slave, poll I2CSTR.AAS
I2caRegs.I2CIER.bit.ARBL = 0; // Arbitration lost, poll I2CSTR.ARBL
I2caRegs.I2CIER.bit.ARDY = 0; // Register access ready, poll I2CSTR.ARDY
I2caRegs.I2CIER.bit.NACK = 0; // No-acknowLEDgement, poll I2CSTR.NACK
I2caRegs.I2CIER.bit.RRDY = 0; // [USED IN NON-FIFO MODE ONLY]Receive data ready, poll I2CSTR.RRDY
I2caRegs.I2CIER.bit.SCD = 0; // Stop condition detected, poll I2CSTR.SCD
I2caRegs.I2CIER.bit.XRDY = 0; // [USED IN NON-FIFO MODE ONLY]Transmit data ready, poll I2CSTR.XRDY
I2caRegs.I2CMDR.all = 0x0020; // [RECOMMENDED IN NON-INIT OPERATION] 0000 0010 0010 0000

Green Deng:你好,型号是TMS320F28027?
从机的接收中断标志位等等有响应吗?

下面是I2C作为从机的初始化:主机对从机操作,从机没有应答

// Step1: Config Own Address (work as a slave device)
I2caRegs.I2COAR = 0x0050;

// Step2: Config Module Clock
// I2CCLK = SYSCLK/(I2CPSC+1)
#if (CPU_FRQ_40MHZ||CPU_FRQ_50MHZ)
I2caRegs.I2CPSC.all = 4; // Prescaler – need 7-12 Mhz on module clk
#endif

#if (CPU_FRQ_60MHZ)
I2caRegs.I2CPSC.all = 6; // Prescaler – need 7-12 Mhz on module clk
#endif

// Step3: Config I2C Bus SCLK clock

// Step4: Config I2C Interrupt Source
// Reference: User Guide Page26; Enable = 1, Disable = 0
I2caRegs.I2CIER.bit.AAS = 1; // Addressed as slave, poll I2CSTR.AAS
I2caRegs.I2CIER.bit.ARBL = 0; // Arbitration lost, poll I2CSTR.ARBL
I2caRegs.I2CIER.bit.ARDY = 0; // Register access ready, poll I2CSTR.ARDY
I2caRegs.I2CIER.bit.NACK = 0; // No-acknowLEDgement, poll I2CSTR.NACK
I2caRegs.I2CIER.bit.RRDY = 0; // [USED IN NON-FIFO MODE ONLY]Receive data ready, poll I2CSTR.RRDY
I2caRegs.I2CIER.bit.SCD = 0; // Stop condition detected, poll I2CSTR.SCD
I2caRegs.I2CIER.bit.XRDY = 0; // [USED IN NON-FIFO MODE ONLY]Transmit data ready, poll I2CSTR.XRDY
I2caRegs.I2CMDR.all = 0x0020; // [RECOMMENDED IN NON-INIT OPERATION] 0000 0010 0010 0000

mangui zhang:抓时序看看写完地址后有没有响应取保地址是对的读写操作是对的
IIC总线上拉配置是对的

下面是I2C作为从机的初始化:主机对从机操作,从机没有应答

// Step1: Config Own Address (work as a slave device)
I2caRegs.I2COAR = 0x0050;

// Step2: Config Module Clock
// I2CCLK = SYSCLK/(I2CPSC+1)
#if (CPU_FRQ_40MHZ||CPU_FRQ_50MHZ)
I2caRegs.I2CPSC.all = 4; // Prescaler – need 7-12 Mhz on module clk
#endif

#if (CPU_FRQ_60MHZ)
I2caRegs.I2CPSC.all = 6; // Prescaler – need 7-12 Mhz on module clk
#endif

// Step3: Config I2C Bus SCLK clock

// Step4: Config I2C Interrupt Source
// Reference: User Guide Page26; Enable = 1, Disable = 0
I2caRegs.I2CIER.bit.AAS = 1; // Addressed as slave, poll I2CSTR.AAS
I2caRegs.I2CIER.bit.ARBL = 0; // Arbitration lost, poll I2CSTR.ARBL
I2caRegs.I2CIER.bit.ARDY = 0; // Register access ready, poll I2CSTR.ARDY
I2caRegs.I2CIER.bit.NACK = 0; // No-acknowLEDgement, poll I2CSTR.NACK
I2caRegs.I2CIER.bit.RRDY = 0; // [USED IN NON-FIFO MODE ONLY]Receive data ready, poll I2CSTR.RRDY
I2caRegs.I2CIER.bit.SCD = 0; // Stop condition detected, poll I2CSTR.SCD
I2caRegs.I2CIER.bit.XRDY = 0; // [USED IN NON-FIFO MODE ONLY]Transmit data ready, poll I2CSTR.XRDY
I2caRegs.I2CMDR.all = 0x0020; // [RECOMMENDED IN NON-INIT OPERATION] 0000 0010 0010 0000

K Mr:抓下波形,看下从机有没有响应

赞(0)
未经允许不得转载:TI中文支持网 » STM32F28027 I2C配置为从机,没有应答信号
分享到: 更多 (0)