完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我是微芯片,这个论坛,我已经真正陷入困境。我使用PIC24FJ128GA202试图写数据到一个微SD卡。我使用的是MPLAB X V3.3和ICD3。我正在将微芯片应用程序库(MLA)用于文件系统,现在我正试图修改fileio代码中的示例来处理我的图片。使用调试器逐步检查代码,我发现它正在等待SPIRBE位来指示接收缓冲区中存在信息,但是该位永远不会被设置。我还试着继续调试,让它运行5分钟左右,但是它仍然停留在while循环中。调用堆栈isSPI1_ExchangeBuffer(uint16_t len=0x0200,void*pRecieveData=0,void*pTransmitData=30)DRV_SPI_GetBuffer()FILEIO_SD_AsyncReadTasks()FILEIO_SD_SectorRead()FILEIO_LoadMBR()FILEIO_DriveMount()main()我的设置已经连接了SPI、SDO、SDO、以及D SCK线从MICROSD卡插座到可编程外围引脚与一个47 K电阻拉到地上对我的PCB。后来,我注意到,MLA代码切换芯片选择关闭,并在SD卡上,所以我焊接线连接RPB13到CS。如果没有CS连接,程序中的DRIVEMUnt函数将在调试时返回FieloEyErrOrthInITHOLL错误。在示意图中,R5、R6、R7 I已经放置0欧姆电阻,而R8、R9、R10是47 K下拉。VDD是3V。我检查了焊接,所有SD卡线路都连接到PIC,它们没有短路在一起。我已经在MLA中为MIC24FJ128GA202中的FLIIO代码修改了这个例子。除了用户实现的功能和LED的调试外,大部分都保持不变。我试图在SD卡SPI 6012A故障排除帖子中进行更改。http://www..hip.com/for./FindPost/842460A。缓冲模式,设置系统频率。我使用drv_spi_16bit_v2.c,因为它具有正确的SFR名称(例如SPIxCON1L、SPIxSTATH、SPIxSTATL而不是SPIxCON1、SPIxSTAT)。我没有做出他的改变或类似的改变,因为据我所知,他的改变是不必要的,因为。看起来和原始代码一样,#i#是一个宏,用括号中的数字i替换##i####,这是他所做的全部更改,将其替换为通道1。我还尝试过启用软件MediaDetect,但是插入时它没有检测到驱动器。sd_spi_config.hI中的SOFT_DETECT也使用通道1I,注意到它说MLA库使用HC振荡器,并且我正在使用FRC振荡器,并且我想知道代码是否只与HC振荡器一起工作?我的相关振荡器配置是初始振荡器是FRC,PLL禁用PLL输入是FRCPrimary振荡器禁用I设置define SYS_CLK_FrequencySystemGet()和所有其他定义频率都为8000000,我试过7370000,没有任何改变。我试过使用PLL(4x),更新系统频率,并将其设置为FRCDIV,但是DriveMount函数返回FILEIO_ERROR_INIT_ERROR。我已将其格式化为FAT32,配置大小为8192字节。我已经尝试重新格式化它,并且具有不同的分配大小。根据数据表,它应该支持SPI模式,工作电压是2.7-3.6V。我不知道我是否包括了调试所需的所有代码,所以如果您需要的话,我可以发布更多的代码,我认为在这里粘贴整个main.c不是个好主意。提前感谢。
以上来自于百度翻译 以下为原文 Hi I am new to microchip, and this forum, and I have gotten really stuck. I am using PIC24FJ128GA202 to try to write data to an microSD card. I am using MPLAB X v3.3, and ICD3. I am using the Microchip Libraries for Applications (MLA) for the filesystem, and right now I am trying to adapt the example in the fileio code to work on my pic. Using the debugger to step through the code, I found that it is waiting for the SPIRBE bit to indicate that there is information in the recieve buffer, but the bit never gets set. I have also tried continuing in debug and letting it run for 5 min or so, but it still stuck in the while loop. This is in the FILEIO_DriveMount function. while (count) { if (SPI1STATLbits.SPIRBE == false) { *pReceived = SPI1BUFL; pReceived += receiveAddressIncrement; count--; } } The call stack is SPI1_ExchangeBuffer(uint16_t len = 0x0200, void* pRecieveData =0, void * pTransmitData =30) DRV_SPI_GetBuffer() FILEIO_SD_AsyncReadTasks() FILEIO_SD_SectorRead() FILEIO_LoadMBR() FILEIO_DriveMount() main() My setup I have connected the SPI, SDO, and SCK lines from the microSD card socket to programmable peripheral pins with a 47k resistor pull down to ground on my PCB. Later, I noticed that the MLA code toggles the Chip select to turn off and on the SD card so I soldered a wire connecting RPB13 to CS. Without the CS connected, the DriveMount function in the program will return FILEIO_ERROR_INIT_ERROR when debugging. In the schematic, R5, R6, R7 I have put 0 ohm resistors, and R8, R9, R10 are the 47k Pull down. VDD is 3V. I checked the soldering and all the SD card lines are connected to the PIC, and none of them are shorted together. I have adapted the example from the fileio code in the MLA for my PIC24FJ128GA202. Most of it is unchanged except for the user implemented functions and debugging LED. I have tried making the changes in SD card SPI 6012A troubleshooting post. http://www.microchip.com/forums/FindPost/842460 As stated in that post, I set CD to return true always, WP to return false, disabled enhanced buffer mode, and set my system frequency. I am using the drv_spi_16bit_v2.c since this has the right SFR names (such as SPIxCON1L, SPIxSTATH, SPIxSTATL instead of SPIxCON1, SPIxSTAT). I did not make the changes he made or similar to it since, as far as I can tell, his changes were unnecessary because. It seems like the in original code, the ##i## is a macro that replaces the ##i## with the number i in parenthesis, which is all he his change was, replacing it to channel 1. #define DRV_SPI_STATL(i) SPI##i##STATL #define DRV_SPI_STATLbits(i) SPI##i##STATLbits #define DRV_SPI_STATH(i) SPI##i##STATH //etc I have also tried enabling software MediaDetect but it does not detect the drive when inserted. #define FILEIO_SD_CONFIG_MEDIA_SOFT_DETECT in sd_spi_config.h I am also using channel 1 I notice that it says the MLA library uses HC oscillator, and I am using the FRC oscillator, and I wonder if the code will only work with HC oscillator? My relevant oscillator configurations are
I configured the PPS as shown below void USER_SdSpiConfigurePins (void) { //TODO configure pins with PPS for spi //RPINR0 = 7; //set INT0 interupt input to pin RP7 __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS RPINR20bits.SDI1R = 4; //set SPI input to RP4 RPOR2bits.RP5R = 7 ; //set RP5 as SDO RPOR3bits.RP6R = 8 ; //set RP6 to SCK output __builtin_write_OSCCONL(OSCCON | 0x40); // lock PPS TRISBbits.TRISB13 = 0; //configure CS pin as output } I am using a SanDisk 4Gb MicroSDHC card. I have formatted it to FAT32 with allocation size 8192 bytes. I have tried reformatting it, and with different allocation sizes. According the the datasheet, it should support SPI mode, and operating voltage is 2.7-3.6V. I don't know if I have included all the necessary code for debugging, so I can post more code if you need it, I didn't think it was a good idea to paste my entire main.c in here. Thanks in advance. |
|
相关推荐
1个回答
|
|
好的,我发现我在尝试在32 MHz时出错,因为它应该是FRCPLL,而不是FRCdIV。但是,这并不能解决此问题,因为它仍然停留在while循环中,等待SPI1STATLbits.SPIRBEEDIT:刚刚注意到如何编辑。这里是我的配置设置与4xPLL。它仍然停留在原来的职位相同的地方。
以上来自于百度翻译 以下为原文 Ok i found i was making a mistake when trying at 32Mhz, as it should be FRCPLL, not FRCDIV. However, this does not solve the issue, as it is still stuck in the while loop waiting for SPI1STATLbits.SPIRBE EDIT: just noticed how i can edit. here are my config settings for with 4x PLL. It is still getting stuck in the same place as in the original post. #include // PIC24FJ128GA202 Configuration Bit Settings // 'C' source line config // CONFIG4 #pragma config DSWDTPS = DSWDTPS1F // Deep Sleep Watchdog Timer Postscale Select bits (1:68719476736 (25.7 Days)) #pragma config DSWDTOSC = LPRC // DSWDT Reference Clock Select (DSWDT uses LPRC as reference clock) #pragma config DSBOREN = ON // Deep Sleep BOR Enable bit (DSBOR Enabled) #pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer Enable (DSWDT Enabled) #pragma config DSSWEN = ON // DSEN Bit Enable (Deep Sleep is controlled by the register bit DSEN) #pragma config PLLDIV = PLL4X // USB 96 MHz PLL Prescaler Select bits (4x PLL selected) #pragma config I2C1SEL = DISABLE // Alternate I2C1 enable bit (I2C1 uses SCL1 and SDA1 pins) #pragma config IOL1WAY = OFF // PPS IOLOCK Set Only Once Enable bit (The IOLOCK bit can be set and cleared using the unlock sequence) // CONFIG3 #pragma config WPFP = WPFP127 // Write Protection Flash Page Segment Boundary (Page 127 (0x1FC00)) #pragma config SOSCSEL = OFF // SOSC Selection bits (Digital (SCLKI) mode) #pragma config WDTWIN = PS25_0 // Window Mode Watchdog Timer Window Width Select (Watch Dog Timer Window Width is 25 percent) #pragma config PLLSS = PLL_FRC // PLL Secondary Selection Configuration bit (PLL is fed by the on-chip Fast RC (FRC) oscillator) #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset Enable) #pragma config WPDIS = WPDIS // Segment Write Protection Disable (Disabled) #pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select (Disabled) #pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select (Write Protect from WPFP to the last page of memory) // CONFIG2 #pragma config POSCMD = NONE // Primary Oscillator Select (Primary Oscillator Disabled) #pragma config WDTCLK = LPRC // WDT Clock Source Select bits (WDT uses LPRC) #pragma config OSCIOFCN = OFF // OSCO Pin Configuration (OSCO/CLKO/RA3 functions as CLKO (FOSC/2)) #pragma config FCKSM = CSDCMD // Clock Switching and Fail-Safe Clock Monitor Configuration bits (Clock switching and Fail-Safe Clock Monitor are disabled) #pragma config FNOSC = FRCPLL // Initial Oscillator Select (Fast RC Oscillator with PLL module (FRCPLL)) #pragma config ALTCMPI = CxINC_RX // Alternate Comparator Input bit (C1INC, C2INC and C3INC are on RB9) #pragma config WDTCMX = WDTCLK // WDT Clock Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits) #pragma config IESO = OFF // Internal External Switchover (Disabled) // CONFIG1 #pragma config WDTPS = PS32768 // Watchdog Timer Postscaler Select (1:32,768) #pragma config FWPSA = PR128 // WDT Prescaler Ratio Select (1:128) #pragma config WINDIS = OFF // Windowed WDT Disable (Standard Watchdog Timer) #pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT disabled in hardware; SWDTEN bit disabled) #pragma config ICS = PGx1 // Emulator Pin Placement Select bits (Emulator functions are shared with PGEC1/PGED1) #pragma config LPCFG = OFF // Low power regulator control (Disabled - regardless of RETEN) #pragma config GWRP = OFF // General Segment Write Protect (Write to program memory allowed) #pragma config GCP = OFF // General Segment Code Protect (Code protection is disabled) #pragma config JTAGEN = OFF // JTAG Port Enable (Disabled) |
|
|
|
只有小组成员才能发言,加入小组>>
5006 浏览 9 评论
1923 浏览 8 评论
1853 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3067 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2143 浏览 5 评论
577浏览 1评论
432浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
476浏览 0评论
367浏览 0评论
IPECMD命令烧录AVR128DA48芯片,报找不到芯片错误
853浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-17 10:12 , Processed in 2.021435 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191