完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
我有一个DSPIC33 EP256MU806,我正试图使用FATFS库将文件写入SD卡。我已经有了Microchip的MLA库,但是写速度不够,所以我要修改FATFS。当我尝试做fyMAMT时,它会返回FrxNothRead,这意味着硬件层中的一些东西配置得不好。我使用的是FCY= 16MHz,并且我检查了SPI时钟是使用了33kHz。一个示波器。下面的两个配置都在我的主叫中被调用。这是我的SPI配置:这里是我的PPS配置:我重新定义了TX和RX函数来使用MCC生成的函数:有人知道我做错了什么吗?
以上来自于百度翻译 以下为原文 I have a dspic33ep256mu806 and I'm trying to write a file to an sd card using the FatFs library. I've already got microchip's mla library working but the write speed wasn't enough so I'm changing to fatfs. When I try to do f_mount, it returns FR_NOT_READY, meaning that something in the hardware layer is poorly configured. I'm using FCY = 16MHz and I've checked that the SPI clock is 333KHz using an oscilloscope. Both configurations below are being called in the beginning of my main. Here is my SPI configuration: SPI1STATbits.SPIEN = 0; //Assure module is disabled /* SPI1CON1 */ SPI1CON1bits.DISSCK = 0; SPI1CON1bits.DISSDO = 0; SPI1CON1bits.MODE16 = 0; SPI1CON1bits.SSEN = 0; SPI1CON1bits.MSTEN = 1; /* Timing configuration */ SPI1CON1bits.CKP = 0; SPI1CON1bits.CKE = 1; SPI1CON1bits.SMP = 0; /* Chose baudrate prescalers */ SPI1CON1bits.PPRE = 1; SPI1CON1bits.SPRE = 5; /* SPI1CON2 */ SPI1CON2bits.FRMEN = 0; // Disable all framed SPI support SPI1CON2bits.SPIBEN = 1; // Enhanced mode is enabled /* SPI1STAT */ SPI1STATbits.SPISIDL = 0; // continue operation in Idle SPI1STATbits.SPIROV = 0; // Clear overflow SPI1STATbits.SISEL = 0b011; // Set interrupt to SPI receive buffer full is set (Not used) SPI1STATbits.SPIEN = 1; Here is my PPS configuration: /* Configure SPI Pins */ /* SDI - E6(RP86) * SDO - E4(RP84) * SCK - E5(RP85) * CS - E7(RP86) */ LATEbits.LATE7 = 1; TRISEbits.TRISE7 = 0; TRISEbits.TRISE6 = 1; TRISEbits.TRISE4 = 0; TRISEbits.TRISE5 = 0; PPSUnLock; PPSInput(IN_FN_PPS_SDI1, IN_PIN_PPS_RP86); PPSOutput(OUT_FN_PPS_SDO1, OUT_PIN_PPS_RP84); PPSInput(IN_FN_PPS_SCK1, IN_PIN_PPS_RP85); PPSOutput(OUT_FN_PPS_SCK1, OUT_PIN_PPS_RP85); PPSLock; I've redefined the tx and rx functions to use the MCC generated function: void SPI1_Exchange( uint8_t *pTransmitData, uint8_t *pReceiveData ) { while( SPI1STATbits.SPITBF == true ) { } if (SPI1_TransferModeGet() == SPI_TRANSFER_MODE_16BIT) SPI1BUF = *((uint16_t*)pTransmitData); else SPI1BUF = *((uint8_t*)pTransmitData); while ( SPI1STATbits.SRXMPT == true); if (SPI1_TransferModeGet() == SPI_TRANSFER_MODE_16BIT) *((uint16_t*)pReceiveData) = SPI1BUF; else *((uint8_t*)pReceiveData) = SPI1BUF; return; } uint8_t sd_rx(){ uint8_t receive; SPI1_Exchange(NULL, &receive); return receive; } void sd_tx(uint8_t data){ SPI1_Exchange(&data, NULL); } Anyone's got an idea of what I'm doing wrong? |
|
相关推荐
11个回答
|
|
|
你传递的是空指针,而不是检查它们。(我会帮助更多,但是论坛是不可用的,就像整个星球一样)
以上来自于百度翻译 以下为原文 you're passing null pointers, and not checking for them. (I'd help more but the forum is unusable, just like this whole planet) |
|
|
|
|
|
|
|
|
|
|
|
你是说SDJTX和SDYRX功能吗?SPI1X Exchange(..)的文档是:*@简短地交换数据的一个元素。发送或接收**PARAM pSimultDATA数据元素来发送。仅接收**时,NULL。*@ PARAM PNEVEDATA数据元素接收。仅当发送时为空。因此,当我要读取时,在发送指针中发送NULL,而当我要写入时,读取指针中的NULL。
以上来自于百度翻译 以下为原文 Are you talking about the sd_tx and sd_rx functions? The documentation for the SPI1_Exchange(..) is: * @brief Exchange one element of data. Transmit or receive * * @param pTransmitData Data element to send. NULL when receiving * only. * @param pReceiveData Data element to receive. NULL when * transmitting only. So I send NULL in the transmit pointer when I want to read and NULL in the read pointer when I want to write. |
|
|
|
|
|
我检查了我的SPI时钟确实是33 3kHz,并且我可以在示波器上看到总线上的数据,所以我想是这样。
以上来自于百度翻译 以下为原文 I checked that my SPI clock is indeed 333KHz and I can see data on the bus with an oscilloscope, so I think so. |
|
|
|
|
|
这是奇怪的:从上面的代码,当一个空通过(在这两个地方),函数试图使用它(他们)反正。这将导致该PIC的异常。
以上来自于百度翻译 以下为原文 It's strange then: from the code above, when a NULL is passed (in both places) the function tries to use it (them) anyway. This should cause an exception on that PIC |
|
|
|
|
|
这不应该发生。但是,我增加了一张支票。仍然不工作。
以上来自于百度翻译 以下为原文 That should never happen. However, I've added a check. Still not working. |
|
|
|
|
|
为什么你说MLA的代码不够快?你想要什么速度?SD卡上的SPI接口并不是一个特别快的接口。
以上来自于百度翻译 以下为原文 Why do you say the code from the MLA is not fast enough? What speed are you wanting? The SPI interface on an SD card is not a particularly fast interface anyway. |
|
|
|
|
|
嗨,你提到MLA不够快,你只运行SPI@ 33 3kHz????当做
以上来自于百度翻译 以下为原文 Hi, You mentioned that MLA is not fast enough and you only run SPI @ 333kHz ??? Regards |
|
|
|
|
|
|
|
|
|
|
|
如果我记得正确的话,33KHz可以是SD卡的“启动阶段”。然后应该增加
以上来自于百度翻译 以下为原文 333KHz could be the "startup phase" of the SDcard, if I recall correctly. Then it should increase |
|
|
|
|
|
初始化慢,然后将SPI设置为10MHz。这就是我在SD卡库中所做的,并以全速运行MPU。
以上来自于百度翻译 以下为原文 Initialize slow then set SPI to 10MHz. That's what I did in my sdcard library and run the mpu at full speed. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1123浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 01:54 , Processed in 0.961584 second(s), Total 92, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2182