完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,我是一个嵌入式编程初学者。我在SPICI模式下使用PIC16F87A和SD卡。我需要一个小小的说明。我得到的传感器数据每秒80-100字节。我想把它存储在SD卡中。有人能告诉我,我们能在单块WR中只写100个字节吗?IT/Read(CMD24/CMD17)?或者我们必须一次写入整个块(512字节)?提前感谢。
以上来自于百度翻译 以下为原文 Hello folks, I am a beginner in embedded programming. I am working with PIC16F877A and SD card via SPI mode. I need a small clarification. I am getting sensors data of 80-100 bytes per second. I want to store it in SD card. Can anyone please tell me that can we write/read only 100 bytes in Single block write/read (CMD24/CMD17) respectively ? Or we have to write whole block (512 bytes) at a time ? Thanks in advance. |
|
相关推荐
19个回答
|
|
|
如果SD卡被格式化为FAT(FAT12、FAT16、FAT32等)的形式,则通常以扇区-时间-方法(512字节/扇区)访问数据。在这些格式写少于一个完整的扇区(512字节),你基本上读取扇区,修改你想写的部分,然后写回整个扇区。不允许/支持(比我所知)更小的读/写。在其他系统(非FATXX)中格式化的SD卡可能是不同的。还要注意一些SD卡栈(SD卡库)(FAT系统这样做)将访问卡的集群,而不是扇区(每个扇区的多个扇区)作为最小存储“块”。个人部门的准入仍然是可能的,但必须认真完成。检查图书馆提供的功能以确保。(假设您正在使用一些库来访问SD卡)。
以上来自于百度翻译 以下为原文 If the SD card is formatted with a form of FAT (FAT12,FAT16,FAT32 etc) then you generally access the data in a sector-at-a-time method (512 bytes/sector). In these formats to write less than a full sector (512 bytes) you basically read the sector, modify the part you wish to write, and then write the entire sector back. Reading/writing smaller than a sector is not allowed/supported (as far as I know). SD cards formatted in other systems (non FATxx) may be different. Also be aware some SD card stacks (SD card libraries)(FAT systems do this) will accesss the card in clusters, not sectors (multiple sectors per clustor) as the minimum storage "chunk". Individual sector access is still possible but must be carefully done. Check the functions provided by the library to be sure. (assuming you are using some library to access the SD card). |
|
|
|
|
|
为什么像PIC16F87A那样使用一个古老的PIC?你可以在相同的软件包中获得较新的PIC16F芯片,该处理器使用较少的功率,内部振荡器具有更多的内部RAM和ROM成本。
以上来自于百度翻译 以下为原文 Why work with an ancient PIC like a PIC16F877A? You can get newer PIC16F chips in the same package that
|
|
|
|
|
|
你好,杰克,谢谢你的回复。我使用SPI模式,不使用FAT。
以上来自于百度翻译 以下为原文 Hello jack, Thanks for the reply. I am using SPI mode, and not using FAT. |
|
|
|
|
|
|
|
|
|
|
|
是的,这是读/修改/写的情况。帐户跨越两个扇区的数据,并考虑需要访问群集表的群集。FAT16/FAT32。您可以缓冲这些块,并修改表,这样集群就不需要从表中获取数据。您的数据可以跨越两个可以在SD-CAR上任何地方存在的集群。如果PIC将写入数据并读取它,则不需要使用文件系统。你必须遵守规则,创建可以是短文件或长文件名的FAT条目。提示:在Windows中创建一个1字节的文件,它将占据一个可能是X扇区的簇。如果将簇大小设置为8个扇区,它将给你4096个字节。进入时。
以上来自于百度翻译 以下为原文 Yeah, it is the case of read/modify/write. Account for data crossing two sectors and account for clusters which will require access to the cluster table. fat16/fat32. You can buffer chunks of this and modify the table so that clusters do not need a fetch from the table. Your data may cross two clusters that can exist anywhere on the sd-card. You don't need to use a file system if the pic will be writing data and reading it back. If you want to see it in Windows then you have to abide by the rules and create fat entries which can be short or long filenames. Tip: Create a 1 byte file in windows, it will occupy a cluster which may be x sectors. If you set cluster size to 8 sectors it will give you 4096 bytes to play with. The filesize needs to be modifyed in the fat entry. |
|
|
|
|
|
好的,SPI和脂肪没有任何关系。SPI是一种用于传输数据的串行协议,FAT(文件分配表)是一种在媒体(SD卡、磁盘驱动器、闪存驱动器等)上组织数据的协议(或如果您愿意的话)。
以上来自于百度翻译 以下为原文 OK, SPI and FAT have nothing to do with each other. SPI is a serial protocol for the transfer of data, FAT (File Allocation Table) is a protocol (or system if you prefer) of organizing the data on the media (SD card, disk drive, Flash drive, etc.). |
|
|
|
|
|
如果您想通过Windows、Linux或大多数其他当前操作系统读取SD卡,那么它最有可能在FAT16或FAT32格式(取决于容量)而被格式化。
以上来自于百度翻译 以下为原文 If you intend the SD card to be read by Windows, Linux or most other current operating systems then it is most likely formatted in FAT16 or FAT32 (depending on capacity). |
|
|
|
|
|
我不想通过Windows检查它,它是一个简单的写/读到SD。
以上来自于百度翻译 以下为原文 I dont want that to check through Windows. Its a plain write/read to SD. |
|
|
|
|
|
下载此:SD卡规格第一部分410跳转到SPI模式。
以上来自于百度翻译 以下为原文 Download this: SDCARD SPECS part1_410 Jump straight to the SPI mode. |
|
|
|
|
|
这意味着你直接读写SD卡而不使用任何格式化?无论哪种方式,这仍然是一次一个扇区,512字节。各扇区分别在LBA模式下进行寻址。
以上来自于百度翻译 以下为原文 So this means you are reading and writing to the SD card directly without using any formatting? Either way this is still done a sector at a time, 512 bytes. The sectors are addressed individually in LBA mode. |
|
|
|
|
|
因此,在SPI模式下,无论是单块读写,我们都必须在扇区中读取/写入整个512字节。
以上来自于百度翻译 以下为原文 So in SPI mode, either single block read/write , we have to read/write whole 512 bytes in a sector. |
|
|
|
|
|
|
|
|
|
|
|
你好,Gort,为了再次澄清,假设我已经在扇区100中写了80个字节。现在如果我从第一百零一个扇区写入没有问题。但是如果我这样做,我将丢失(512~80=432)432字节的内存。因此,如果我想再次在同一扇区上写,我可以跳过最后写的80字节地址吗?在同一扇区中写入另外80字节?请指引我。
以上来自于百度翻译 以下为原文 Hello Gort, Just to clarify again, suppose I have written first 80 bytes in Sector 100. Now If I write from 101th sector there will be no problem. But If I do that, I will lost (512-80 = 432) 432 bytes of memory. So If I want to write on same sector again, can I skip last written 80 bytes addresses and write another 80 bytes in same sector ? Please guide me. |
|
|
|
|
|
不,这里没有免费的午餐。如果你想写整个行业,你必须一劳永逸。
以上来自于百度翻译 以下为原文 No. There's no free lunch here. If you want to write the whole sector, you have to do it in one go. |
|
|
|
|
|
您好QYB,我们可以使用WrreEngBLePult和Read SubLIX部分来设置部分块来写入和读取小于512个字节吗?
以上来自于百度翻译 以下为原文 Hello qyb, Can we set partial blocks using WRITE_BL_PARTIAL and READ_BL_PARTIAL to write and read less than 512 bytes? |
|
|
|
|
|
我假设你正在使用SD卡来访问卡,哪一个?这些看起来像是图书馆的函数。
以上来自于百度翻译 以下为原文 I assume you are using some SD card library to access the card, which one? These look like functions from a library. |
|
|
|
|
|
管理你的部门,保留一些扇区,你可以读取1字节。如果该字节是在位置10。您将下降10,读取1,然后中止与停止传输。创建一个函数。对于:ItSeaTracePrad(ULUN扇区、UINT启动、UINT大小、VULL *缓冲区);//部分RealeRe= SeCtReSyPad(100,10,1,缓冲器);如果您在Windows中创建文本文件,并且文件大小只有1字节,则它将占用磁盘上的1个集群。如果再添加100个字节,它仍然是1个集群。其中1簇是x的扇区量。
以上来自于百度翻译 以下为原文 Manage your sectors, reserve some sectors. You can just read 1 byte. If that byte is i.e. at position 10. You would drop 10, read 1 and then abort with STOP_TRANSMISSION. Create a func. for that: int sector_pread(ulong Sector, uint Start, uint Size, void *Buffer); //partial read err=sector_pread(100,10,1,buffer); If you create a text file in Windows and that file size is only 1 byte, it will occupy 1 cluster on the disk. If you add another 100 bytes, it will still be 1 cluster. Where 1 cluster is x amount of sectors. |
|
|
|
|
|
INTX;Err=SeCurthyPrad(100,10,2,和;X);
以上来自于百度翻译 以下为原文 int x; err=sector_pread(100,10,2,&x); |
|
|
|
|
|
我认为WrimeBLYPART可能在SD卡的早期工作过。(MB卡)它仍然必须是512。我没有看过最新的规格。我原以为它们最多可以达到4096字节。
以上来自于百度翻译 以下为原文 I think the WRITE_BL_PARTIAL may have worked in the early days of sd-cards. (MB cards) It still has to be 512. I haven't read the latest specs. I would have thought they would be up to 4096 bytes. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1121浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
872浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 18:42 , Processed in 1.182327 second(s), Total 108, Slave 91 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
5452