2011-12-28 89 views
0

我有一個數組向下跌破如何將內存中的內容寫入數組?

unsigned char pat6[8] = {0x3C,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0x3C,}; 

我怎樣才能填補的內存,我從這裏閱讀內容的陣列?

unsigned char read_byte()   //reading from EEPROM serially 
{ 
    unsigned int i; 
    sda=1; 
    reead=0; 
    for(i=0;i<8;i++) 
    { 
     reead=reead<<1; 
     scl=1; 
     _nop_(); 
     _nop_(); 
     if(sda==1) 
      reead++; 
     scl=0; 
    } 
    sda=0; 
    return reead;    //Returns 8 bit data here 
}  

由於

void display_clear(unsigned char pattern[])//, int num) 

{ 
    unsigned int cnt, col, row; //, num ; 


    row = 1; 
      //for (cnt = num*8 ; cnt < (num*8+8) ; cnt ++) //display pattern each character 
      for (cnt = 0 ; cnt < 8 ; cnt ++) //display pattern each character 
      { 
       P3 = ~pattern[cnt]; 
       P1 = ~row; 

       delay_ms(100) ; // delay of 1 ms 
       row = row<<1; 


      } 

     row = 0x00; 

} 

朋友,上述函數,我用於顯示陣列..... 我想從串行存儲器

我填寫數組中的數據試圖這樣做:

//begin of read 2048 byte from serial memory AT24C16 

    for (i=0;i<2048;i++) 
     { 
      j[i]=read_byte(); 
      aknowledge(); 
     } 

    //end of read 2048 byte from serial memory AT24C16 

並得到錯誤:

24C16_RW.C(229):錯誤C216:在非數組或維度太多

是否有任何其他方式標?

感謝

+1

什麼是'scl'?它在哪裏宣佈? – 2011-12-28 08:15:28

回答

0

我不知道如果我理解正確你的問題,但我認爲有一個for語句會工作。

for (i=0, i<8,i++) 
pat6[i]=read_byte(); 

什麼我不明白是讀功能怎麼會知道如何按順序讀取。我認爲在這個實現中,整個數組將被填充相同的字節。

+0

亞,我怎麼read_byte並按順序放入數組? – 2011-12-28 09:32:33

0

請按照下面的僞代碼。

function write_into_array() 
{ 
    for i=0 to 8 { 
     array[i] = value-to-be-stored; 
    } 
} 

但是在你的代碼中,scl變量在哪裏聲明?或者它是一個全局變量,就像pat6[]數組?

OTOH,你應該在最後擺脫額外的,

unsigned char pat6[8] = {0x3C,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0x3C,}; 
相關問題