0

私はSPI通信に取り組んでいます.SST25VF032B(32 MBのマイクロチップSPIフラッシュ)を通信しようとしています. 製造元 ID を読み取ると、MF_ID =>4A25BF と表示されますが、本来は MF_ID =>BF254A です。私はそれを単純に逆に取得しています。つまり、最初に3バイト目と3バイト目を最初に噛むことを意味します。

その理由として何が考えられるでしょうか?私の SPI Init 関数は次のとおりです。

//Enable clock control register CLKCON 18 Bit enables SPI  
CLKCON |= (0x01 << 18);//0x40000;  
printk("s3c2440_clkcon=%08ld\n",CLKCON);
//Enable GPG2 Corresponding NSS port
GPGCON =0x1011;//010000 00 01 00 01
printk("s3c2440_GPGCON=%08ld\n",GPGCON);
SPNSS0_ENABLE(); 
//Enable GPE 11,12,13,Corresponding MISO0,MOSI0,SCK0 = 11 0x0000FC00
GPECON &= ~((3 << 22) | (3 << 24) | (3 << 26));  
GPECON |=  ((2 << 22) | (2 << 24) | (2 << 26));  
//GPEUP Set; all disable  
GPGUP &= ~(0x07 << 2);    
GPEUP |=  (0x07 << 11);
//SPI Register section
//SPI Prescaler register settings,  
//Baud Rate=PCLK/2/(Prescaler value+1)  
SPPRE0 = 0x18;       //freq = 1M 
printk("SPPRE0=%02X\n",SPPRE0);  

//polling,en-sck,master,low,format A,nomal = 0 | TAGD = 1  
SPCON0 = (0<<5)|(1<<4)|(1<<3)|(0<<2)|(0<<1)|(0<<0);  
printk("SPCON1=%02ld\n",SPCON0);  

//Multi-host error detection is enabled 
SPPIN0 = (0 << 2) | (1 << 1) | (0 << 0);  
printk("SPPIN1=%02X\n",SPPIN0);  

//Initialization procedure
SPTDAT0 = 0xff;

私の spi_read_write 関数は次のとおりです。

static char spi_read_write (unsigned char outb) 
{
   // Write and Read a byte on SPI interface.  

   int j = 0;  
   unsigned char inb;
   SPTDAT0 = outb;  
   while(!SPI_TXRX_READY) for(j = 0; j < 0xFF; j++);  
   SPTDAT0 = outb;
   //SPTDAT0 = 0xff;  
   while(!SPI_TXRX_READY) for(j = 0; j < 0xFF; j++);   
   inb = SPRDAT0; 
   return (inb);   
}

私の通話機能は次のとおりです。

   MEM_1_CS(0);
   spi_read_write(0x9F);
   m1 = spi_read_write(0x00);
   m2 = spi_read_write(0x00);
   m3 = spi_read_write(0x00);
   MEM_1_CS(1); 
   printk("\n\rMF_ID =>%02X-%02X-%02X",m1,m2,m3); 

何をすべきか教えてください。前もって感謝します!!

4

2 に答える 2