书中介绍,SSPSTAT一共有5中有效状态:
State 1: Master Write, Last Byte was an Address
S = 1, D_A = 0, R_W = 0, BF = 1
State 2: Master Write, Last Byte was Data
S = 1, D_A = 1, R_W = 0, BF = 1
State 3: Master Read, Last Byte was an Address
S = 1, D_A = 0, R_W = 1, BF = 0
State 4: Master Read, Last Byte was Data
S = 1, D_A = 1, R_W = 1, BF = 0
State 5: Master NACK
S = 1, D_A = 1, R_W = 0, BF = 0
7为地址从机模式有两种:
SSPCON1=0x36 // I2C Slave mode, 7-bit address
SSPCON1=0x3e // I2C Slave mode, 7-bit address, START and STOP interrupts enabled
当设0x3e模式时,中断后由于我的应用置涉及到发送指令,主机不对我进行读取,所以S1,S2都可以正常进入;当设0x36模式时,中断后,无法进入S1,S2状态,查看寄存器SSPSTAT S = 0, D_A = 0, R_W = 0, BF = 1, P = 1(无效状态),因此判断单片机检测不到START信号,却检测到了STOP信号,接收异常。原因查找中…
阅读(1338) | 评论(0) | 转发(0) |