现在问题是通过SPI读RC522默认的寄存器数据正常,
执行如下代码后
for(i=0;i<=0x20;i++){ //0x3f
WriteRawRC(FIFODataReg,5);
}
for(i=0;i<=0x20;i++){ //0x3f
temp_data = ReadRawRC(FIFODataReg);
printf("%xh:%xh \n",i,temp_data);
}
数据正确,打印结果如下:
0h:0h --->这个结果错误,其他都正确。
1h:5h
2h:5h
3h:5h
4h:5h
5h:5h
6h:5h
7h:5h
8h:5h
9h:5h
ah:5h
bh:5h
ch:5h
dh:5h
eh:5h
fh:5h
10h:5h
11h:5h
12h:5h
13h:5h
14h:5h
15h:5h
16h:5h
17h:5h
18h:5h
19h:5h
1ah:5h
1bh:5h
1ch:5h
1dh:5h
1eh:5h
1fh:5h
20h:5h
修改为如下代码后:
for(i=0;i<=0x20;i++){ //0x3f
WriteRawRC(FIFODataReg,i); //------>修改为i //
delay(temp_data);
}
for(i=0;i<=0x20;i++){ //0x3f
temp_data = ReadRawRC(FIFODataReg);
printf("%xh:%xh \n",i,temp_data);
}
打印结果如下:
0h:0h
1h:0h
2h:0h
3h:0h
4h:0h
5h:0h
6h:0h
7h:0h
8h:0h
9h:0h
ah:0h
bh:0h
ch:0h
dh:0h
eh:0h
fh:0h
10h:0h
11h:0h
12h:0h
13h:0h
14h:0h
15h:0h
16h:0h
17h:0h
18h:0h
19h:0h
1ah:0h
1bh:0h
1ch:0h
1dh:0h
1eh:0h
目前可以肯定读正常,写的波形也正常,具体出错的原因不明,高手请指导下,谢谢!! |