📄 crcbit.m
字号:
%****************************************************************
% 内容概述:crcbit for GSM
% 创 建 人:李彩
% 单 位:Starpoint
% 创建时间:2008年
%参考TS 45.003
%****************************************************************
function crcoutput=crcbit(data,CRCNo)
len_crc = size(data,2);
switch (CRCNo)
case 3,
crcpoly=[1 0 1 1];
case 6,
crcpoly=[1 1 0 1 1 1 1];
case 10,
crcpoly=[1 0 1 0 1 1 1 0 1 0 1];
case 16,
crcpoly=[1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1];
case 40,
crcpoly = zeros(1,41);
crcpoly(1) = 1;
crcpoly(15) = 1;
crcpoly(18) = 1;
crcpoly(24) = 1;
crcpoly(38) = 1;
crcpoly(41) = 1;
otherwise,
disp('CRC位数错误!请重新调用函数');
end
%crcdata=[data zeros(1,CRCNo)];
temp(1:len_crc)=data;
temp(len_crc+1:len_crc+CRCNo) = 0;
for ii=1:(len_crc)
temp(ii:ii+CRCNo)=mod(temp(ii:ii+CRCNo)+temp(ii)*crcpoly,2);
% temp=[temp(2:CRCNo+1),crcdata(ii+CRCNo+1)];
end
%crcoutput=temp(2:CRCNo+1);
%crcoutput=temp(CRCNo+1:-1:2);%将CRC编码倒序
crcoutput = [data,temp(len_crc+1:len_crc+CRCNo)];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -