资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,3.6,验收滤波器,目 录,验收滤波的作用,SJA1000,验收滤波器原理,SJA1000,延时滤波器设置函数,测试例程,生存者,-,消费者模型,01010101,01010101,01010101,01010101,01010101,01010101,01010101,生产者,消费者,发送,CAN,帧的节点,其发送的数据被网络中的所有消费者接收。,接收,CAN,帧的节点,接收总线上的所有,CAN,帧。,CAN,节点不需要处理所以的,CAN,帧,,CAN,控制器通过滤波器来过滤不需要接收的,CAN,帧。,生产者,消费者,验收滤波作用,验收通过的帧放入接收,FIFO,过滤不需要处理的,CAN,帧,降低主控制器的处理负载。,SJA1000,CAN,内核,验收,滤波器,接收,FIFO,接口管理逻辑,发送缓冲区,收发器,TX,RX,CAN-H,CAN-L,丢弃验收不通过的帧,目 录,验收滤波的作用,SJA1000,验收滤波器原理,SJA1000,延时滤波器设置函数,测试例程,单滤波原理,SJA1000,通过对帧,ID,和数据字节逐位比较,将符合要求的报文存入,RXFIFO,。,同或,ACR,验收代码位,AMR,验收屏蔽位,ACR,+,| AMR,信息位,输出逻辑,=,输出逻辑,信息位,或,&,其它位的比较结果,其它位的比较结果,与,输出逻辑为,1,的帧验收通过,被存入接收,FIFO,单滤波原理真值表,同或,ACR,验收代码位,AMR,验收屏蔽位,输出逻辑,信息位,或,其它位的比较结果,与,0,1,1,1,0,信息位,验收,代码位,验收,屏蔽位,其它位,比较结果,输出,逻辑,X,X,X,有一个,0,0,0,1,0,都为,1,0,1,0,0,都为,1,0,0,0,0,都为,1,1,1,1,0,都为,1,1,X,X,1,都为,1,1,1,1,1,1,0,其它位比较结果有一个为,0,,则验收不通过,1,0,0,0,0,其它位比较结果都为,1,,屏蔽位为,0,,信息位与验收代码位不同,则验收不通过,其它位比较结果都为,1,,屏蔽位为,0,,信息位与验收代码位形同,则验收通过,其它位比较结果都为,1,,屏蔽位为,1,,则验收通过,假设:验收代码寄存器,ACR0ACR3,分别为,0x21,,,0x00,,,0x05,,,0x24,,屏蔽代码寄存器,AMR0AMR3,分别为,0x00,0x00,0x00,0x03,。,ACR3=0X03,ACR2=0X21,AMR1=0X00,AMR0=0X00,ACR2=0X24,ACR2=0X05,ACR1=0X00,ACR0=0X21,AMR0,AMR3,ACR0,ACR3,单滤波标准帧比较规则,待验收的信息位,ID28,ID27,ID21,ID26,ID25,ID24,ID23,ID22,ID20,ID19,ID18,RTR,DB1.7,DB1.6,DB1.0,DB1.5,DB1.4,DB1.3,DB1.2,DB1.1,DB2.7,DB2.6,DB2.0,DB2.5,DB2.4,DB2.3,DB2.2,DB2.1,帧,ID= 0x108,,,RTR = 0,,,DATA2= 0x240x27,,,DATA1= 0x05,的能被验收通过数据帧 。,屏蔽位为,1,的位不做比较,对于标准帧,单滤波模式下比较帧,ID,、,RTR,位和前两个数据字节。,接收到的,CAN,数据,未使用,x,x,0x1,0x0,0x8,0x0,0x5,0x2,0x47,AMR,位为,1,的位对应信息为不做比较,,AMR,为,0,的位对应的信息位与验收代码位相同才能验收通过。,ACR1=0X00,代验收的信息位,ID28,ID27,ID21,ID26,ID25,ID24,ID23,ID22,ID20,ID19,ID18,ID17,ID12,ID11,ID05,ID10,ID09,ID08,ID07,ID06,ID04,ID03,ID02,ID01,ID00,RTR,ID16,ID15,ID14,ID13,ACR3=0X03,ACR2=0X21,AMR1=0X00,AMR0=0X00,ACR2=0X24,ACR2=0X05,ACR0=0X21,AMR0,AMR3,ACR0,ACR3,单滤波扩展帧比较规则,屏蔽位为,1,的位不做比较,对于扩展帧,单滤波模式下比较帧,ID,和,RTR,位。,接收到的,CAN,数据,x,x,AMR,位为,1,的位对应信息为不做比较,,AMR,为,0,的位对应的信息位与验收代码位相同才能验收通过。,假设:验收代码寄存器,ACR0ACR3,分别为,0x21,,,0x00,,,0x05,,,0x24,,屏蔽代码寄存器,AMR0AMR3,分别为,0x00,0x00,0x00,0x03,。,帧,ID= 0x42002A4,,,RTR = 1,远程帧能被验收通过。,0x4,0xA,0x2,0x0,0,0,0,0,0x0,0x2,0x4,0x0,双滤波原理,双滤波器定义了两组比较规则,每组规则的判断方式与单滤波器模式相同。,相或,其中一个滤波器比较通过,就能接收该帧。,ID28,ID27,ID21,ID26,ID25,ID24,ID23,ID22,ID20,ID19,ID18,RTR,0,0,0,0,0,0,0,0,DB1.7,DB1.6,DB1.0,DB1.5,DB1.4,DB1.3,DB1.2,DB1.1,待验收的信息位,双滤波标准帧比较规则,ID.28 ID.18 = 0x052,的数据帧验收通过。,对于标准帧,滤波器,2,比较帧,ID.28ID.18,和,RTR,位;滤波器,1,比较,ID.28ID.18,、第一个字节和,RTR,位。,假设:验收代码寄存器,ACR0ACR3,分别为,0x21,,,0x10,,,0x05,,,0x24,,屏蔽代码寄存器,AMR0AMR3,分别为,0x00,0x00,0x00,0x00,。,ACR0,0,0,1,0,0,0,0,1,ACR1,0,0,0,1,0,0,0,0,AMR3,0,0,0,0,ACR3,0,1,0,0,滤波器,1,AMR3,0,0,0,0,ACR2,0,0,0,0,0,1,0,1,ACR3,0,0,1,0,滤波器,2,ID.28ID.18 = 0X211,,且第一个字节,=0x04,的数据帧验收通过。,bit74,bit30,接收到的,CAN,数据,接收到的,CAN,数据,ID28,ID27,ID21,ID26,ID25,ID24,ID23,ID22,ID20,ID19,ID18,D17,0,0,0,0,ID16,ID15,ID14,ID13,待验收的信息位,双滤波扩展帧比较规则,ID.28 ID.13 = 0x2110,的帧能被验收通过。,对于扩展帧,两个滤波器都是比较帧的,ID.28ID.13,。,假设:验收代码寄存器,ACR0ACR3,分别为,0x21,,,0x10,,,0x05,,,0x24,,屏蔽代码寄存器,AMR0AMR3,分别为,0x00,0x00,0x00,0x00,。,ID.28ID.18 = 0X0524,的数据帧验收通过。,接收到的,CAN,数据,0,0,0,0,接收到的,CAN,数据,AMR1,0,0,0,0,ACR0,0,0,1,0,0,0,0,1,ACR1,0,0,1,0,滤波器,1,0,0,0,0,0,0,0,0,ACR2,0,0,0,0,0,1,0,1,ACR3,0,0,1,0,0,1,0,0,滤波器,2,目 录,验收滤波的作用,SJA1000,验收滤波器原理,SJA1000,延时滤波器设置函数,测试例程,SJA1000,验收滤波设置函数,void SJA1000_Config_Filter (char mode,char *Filter),SetBitMask(REG_CAN_MOD,RM_AFM_BIT);,if (mode 0) ,SetBitMask(REG_CAN_MOD,AFM_BIT);, else ,ClearBitMask(REG_CAN_MOD,AFM_BIT);,WriteSJARegBlock(REG_CAN_ACR0,Filter,8);,ClearBitMask(REG_CAN_MOD,RM_AFM_BIT);,/,进入复位模式,/,双滤波模式,/,单滤波模式,/,配置验收代码,/,退出复位模式,目 录,验收滤波的作用,SJA1000,验收滤波器原理,SJA1000,延时滤波器设置函数,测试例程,测试例程,void main ( ),timerInit();,SJA1000_RST = 1;,timerDelay(50);,SJA1000_Init(0x00,0x14,SJA_CAN_Filter); /,初始化,SJA100,SJA1000_Config_Filter(0,SJA_CAN_Filer);,for (;) ,if (SJARcvData(STD_SEND_BUFFER,0x00) ,D1 = !D1; / D1,取反,测试方法:,设置,CAN,接收滤波器:,ACR0ACR3,分别为,0x21,0x10,0x05,0x24,AMR0AMR3,分别为,0x00,0x00,0x00,0x03,当接收到报文时,LED,等,D1,闪烁,
展开阅读全文