完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在执行一个带有PIC32 MX27的系统和一个来自Simon的串行SLC NAND闪存。为了让我检查通信(SPI)是否正确,我用一个“读ID”命令(0x9F)运行了一个测试,看我是否从Flash中得到一个答案(这是一个2字节的答案:0x2C和0x36,用于微米和类型)。分别为Flash)。所以,我连接了我的逻辑分析仪来检查SPI信号,我注意到,尽管闪存的答案是正确的,但它并没有按照内存数据表中的精确脉冲序列。它包含了一个奇怪的时间间隔。我附上2张图片和我的代码。第一张图片描绘了在Flash数据表中描述的命令0x9F所需的时间图。第二幅图描绘了来自我的逻辑分析仪的实际信号。正如您将注意到的,在开始之前,命令在FLASH应答之前被连续发送2次(而不是一次)。还有时钟脉冲之间的时间间隔,我不明白。SCK脉冲不应该像数据表一样是一个大脉冲序列吗?我相信我一定在代码中写了一些错误的东西。谢谢你的时间。
以上来自于百度翻译 以下为原文 Hi, I am implementing a system with a PIC32MX274 and a serial SLC nand flash from micron. In order for me to check if the communication (SPI) is correct I ran a test with a "Read ID" command (0x9F) to see if I get an answer from the flash (which is a 2-byte answer: 0x2C and 0x36, for micron and type of flash respectively). So, I connected my logic analyzer to check the SPI signals and I noticed that although the answer from the flash memory is correct, it doesn't follow the exact pulse sequence as in the memory's datasheet. It contains a strange time gap. I attach 2 pictures and my code. The first picture depicts the desired time figure for the command 0x9F depicted in the flash datasheet . The second picture depicts the actual signals from my logic analyzer. As you will notice, at the beginning the command is being sent 2 times in a row (instead of one) before the flash answers . Also there is a time gap between clock pulses which I don't understand. Shouldn't the SCK pulses be one big pulse train without interruptions like the one in datasheet? I believe that I must have written something something the wrong way in the code. Thank you for your time. void pinRemap(void){ //==============================remap pins================================== TRISCbits.TRISC1 = 1; // set this as an input for MISO TRISAbits.TRISA1 = 0; // set this as an output for MOSI TRISAbits.TRISA7 = 0; // set this as an output for CS TRISAbits.TRISA9 = 0; // LED output TRISBbits.TRISB15 = 0; // set this as an output for SCK CFGCONbits.IOLOCK = 0; // unlock RPC1R = 0x06; // re-map SDI2(MISO2) to RC1 pin RPA1R = 0x04; // re-map SDO2(MOSI2) to RA1 pin CFGCONbits.IOLOCK = 1; // lock } void spiInit(void){ //==========================SPI INITIALIZATION============================= SPI2CONbits.ON = 0 ; // SPI OFF IEC1bits.SPI2EIE = 0; // Disable SPI interrupt IEC1bits.SPI2RXIE = 0; // Disable SPI interrupt IEC1bits.SPI2TXIE = 0; // Disable SPI interrupt SPI2STATbits.SPIROV = 0; // Clear overflow flag SPI2BUF = 0; // Clear the receive buffer SPI2BRG = 8; // FSCK = 2.5MHz //SPI2CONbits.MODE16 = 1; SPI2CONbits.ENHBUF = 1; SPI2CON = 0; // reset SPI2CON to be sure and then initialize it SPI2CONbits.MCLKSEL = 0; // PB_CLK used by BRG SPI2CONbits.MSSEN = 1; // SS pin automatically driven SPI2CONbits.CKP = 0; // SCK IDLE = LOW (CPOL) SPI2CONbits.CKE = 1; // Output data changes from idle to active SCK SPI2CONbits.MSTEN = 1; // Master Mode } int main(void) { unsigned char i = 0; ANSELA = 0; // Disable analog mode inputs pinRemap(); // remap pins spiInit(); // initialize spi while(1){ SPI2CONbits.ON = 1; //Enable SPI SPI2BUF = 0x9F; // Write command to buffer SPI2BUF = 0x00; while(!SPI2STATbits.SPIRBF); // Wait until receive buffer is full i = SPI2BUF; // read the answer from the flash which is 0x2C and 0x36 SPI2CONbits.ON = 0; // Disable SPI2 SPI2BUF = 0; // Clear Buffer } return 0; } Attached Image(s) |
|
相关推荐
4个回答
|
|
HiTe逻辑分析仪的信号似乎很好。数据表显示了一个连续信号,因为它只有定时图,没有别的。你在逻辑分析器图像中看到的间隙是你的代码在SPI通道上的每个字节事务之间执行的时间。BTW:你不应该重复SPI逗号。D,直到它得到答复。发送命令,并继续发送空闲字节,直到你得到答案。空闲字节将是0xFF或0x00取决于您的硬件配置。
以上来自于百度翻译 以下为原文 Hi The logic analyzer signals seem good. The datasheet shows a continuos signal because its only timming diagram and nothing else. The gaps you see in your logic analyzer image is the time your code takes to execute between each byte transaction on the SPI channel. BTW: You shouldn't repeat a SPI command until it gets answered. Send the command and than keep sending idle bytes until you get an answer. Idle bytes would be 0xff or 0x00 depending on your hardware configuration. Best regards Jorge |
|
|
|
1)您是否丢失了SS2到特定或指定PIN的重新映射?2)我认为下面的一行不应该被注释出来(现在是什么),因为你想和它一起工作?16位?WordsSPI2CONBITS.MODE16=1;3)如果是真,则意味着SPI2BUF=0x9F;//写入命令缓冲SPI2BUF=0x00;必须是SPI2BUF=0x9F00;//写入16比特命令到Buffer-4),这将允许从设备读取一个16位响应,这意味着无符号char i=0;应该是未签名的SO。RT I=0;注:我是SPI新手2!:)
以上来自于百度翻译 以下为原文 1) Are you missing a re-map of SS2 to a specific or designated pin? 2) I think the following line should not be commented out (which it is right now) because you try to work with ?16 bit? words SPI2CONbits.MODE16 = 1; 3) if 2) is true means that SPI2BUF = 0x9F; // Write command to buffer SPI2BUF = 0x00; must be SPI2BUF = 0x9F00; // Write 16 bit command to buffer 4) this would allow reading of one 16 bit response from the device which means that unsigned char i = 0; should be unsigned short i = 0; Note : I am a SPI Newbie 2! :) |
|
|
|
我不建议使用16位模式与微米闪存,但停留在8位模式。正如豪尔赫所说,不管怎样,所显示的循环不是读取数据的正确方法。MICRON Read ID命令由一个字节命令组成,它将提供2个字节作为响应(制造商ID和设备ID)。这使得3字节超过SPI。对于任何其他命令,这可能不同,特别是取决于读取或写入闪存的字节数。这是纯ID,读取ID返回2字节=1个字。
以上来自于百度翻译 以下为原文 I would not recommend to use 16 bit mode with the Micron flash, but stay with 8 bit mode. As Jorge said, the shown loop is not the right way to read this data, anyway. The Micron Read ID command consists of a one byte command and will deliver 2 bytes as response (Manufacturer ID and Device ID). This makes 3 bytes going over SPI. This may vary for any other command, especially depending on the number of bytes to read or write to flash memory. This was by pure incidence that the Read ID returns 2 bytes = 1 word |
|
|
|
从输出到逻辑分析器,这就是循环的工作方式:1。输入第一个字节到FIFO,启动传输2。输入第二个字节到FIFO3。发送第一个字节后,读取一个字节。4。在发送第二个字节之前关闭SPI!5。转到点1,你永远不会发送第二个字节!间隙是在“同时”循环重复之间。
以上来自于百度翻译 以下为原文 From the output to the logic analyzer, this is how your loop works: 1. Enter the first byte to fifo, start the transmission 2. Enter the second byte to fifo 3. after sending the first byte, read one byte. 4. turn off the spi before sending the second byte! 5. go to point 1 You never send a second byte! The gap is between the "while" loop repetitions . SPIRBF testing is not good in your case albert |
|
|
|
只有小组成员才能发言,加入小组>>
5202 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2243 浏览 5 评论
753浏览 1评论
640浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
544浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
652浏览 0评论
552浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 00:21 , Processed in 1.318324 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号