最近在研究基于Arduino + Si4735 + pu2clr/SI4735的数字收音机,FM功能基本已经ok了,感谢pu2clr开源项目作者 Ricardo Lima Caratti 封装了这么好用的库,电路连接正确的情况下,基本可以秒实现功能!
![](https://blog.k-res.net/wp-content/uploads/2022/12/IMG_5263-768x1024.jpeg)
简单试玩了一段时间后准备挑战下传说中的SSB单边带补丁,结果踩到了一个小坑,使用pu2clr库中的代码:https://github.com/pu2clr/SI4735/blob/master/examples/TOOLS/SI47XX_09_SAVE_SSB_PATCH_EEPROM/SI47XX_09_SAVE_SSB_PATCH_EEPROM.ino,准备将SSB补丁写进AT24C256 eeprom中,结果发现执行代码后,数据写入出现了问题,所有验证过程读回的数据全都是0xFF,patch的name什么的在Arduino IDE的Serial Monitor中看到的也都是乱码,size也都是FF对应的错误数据65535这些…
其实之前已经在主程序中实现了eeprom的读写操作,用于保存手收音机的一些状态,如音量、当前频率,频率步进档位等,都是没问题的,所以硬件部分应该是ok的,于是仔细读了写pu2clr的代码,发现原来问题出在这里:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | void setup() { Serial.begin(9600); while (!Serial) ; // Storing the patch header information strcpy (( char *)eep.refined.patch_id, ( char *)content_id); eep.refined.patch_size = size_content; showMsg( "Storing the patch file.." ); showMsgText( "Patch name.............: %s" , eep.refined.patch_id); showMsgValue( "Size of patch header...: %u bytes." , header_size); showMsgValue( "Size of patch content: %u bytes." , eep.refined.patch_size); // !!! Wire.begin(); uint32_t t1 = millis(); eepromWritePatch(); // Comment the line above and uncomment the line below if you want to clean your eeprom. // clearEeprom(); uint32_t t2 = millis(); showMsgValue( "Finish! Elapsed time: %ul milliseconds." , t2 - t1); showMsg( "Checking the values stored" ); checkPatch(); showMsg( "Finish" ); } |
如果不预先调用下Wire.begin(),就会导致我遇到的这种问题,当然,也有可能是刚玩Arduino,有什么操作姿势不对的问题,不过加上后,确实patch保存eeprom正常了,再回到主程序调用downloadPatchFromEeprom加载SSB补丁也正常了。
博主友情提示:
如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用>>博主专用加密工具v3<<处理后发布,原文只有博主可以看到。
加载更多