• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: 請問陣列範圍會超出嗎的問題?
#4
版主
版主


查看用戶資訊
陣列的宣告要看是要使用 RAM 的空間還是宣告的是常數使用 ROM 的空間。
一般的陣列宣告通常是會使用 RAM 的位置。如果要宣告的是常數固定資料就可以使用 const 的保留字將暫列資料擺放在 ROM(F) 裡,但也是要看 RAM 或 Flash 的時計的容量大小去做宣告。

一般 PIC 的常數陣列宣告,因為是連續位址的設計所以比較不會出問題。但是宣告變數陣列時,因為是擺放在 RAM 的區塊,而 RAM 區塊是用 Bank 的架構設計。PIC16F 128Bytes 一個 Bank, PIC18F 則是 256Bytes 一個 Bank.
所以說如果使用的元件有 1024 Bytes 的 RAM 空間,有沒辦法就直接宣告 1024 個陣列長度,這還要看這顆元件 RAM 的分布情形。
之前的PIC16Fxxx RAM 的架構比較複雜,無法做超過最大 128 Bytes 大小的陣列。新架構的 PIC16F1xxxx 才有新的連續位址的架構,在此新架構下陣列的長度就可以有較大的空間可以宣告。

關於PIC16F1xxxx 新架構的說明,請參考教育訓練光碟裡的教材: XC8T 裡的說明及範例。

發表於: 2021/10/26 12:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問陣列範圍會超出嗎的問題?
#3
管理員
管理員


查看用戶資訊
如果是一個固定的圖檔時, 宣告為 const可以將這塊矩陣改放到Flash中減少SRAM的消耗,
其中因為宣告為常數const, 因此矩陣的 size 也必須是固定的常數, 不能是內容可變的計算式.
#define BUF_SIZE 1024
const uint8_t buffer[BUF_SIZE] = {.....};

發表於: 2021/10/26 7:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問陣列範圍會超出嗎的問題?
#2
新會員
新會員


查看用戶資訊
試著將陣列改小一點試試

static uint8_t buffer[1000]
static uint8_t buffer[512]
static uint8_t buffer[500]

發表於: 2021/10/25 11:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問陣列範圍會超出嗎的問題?
#1
資深會員
資深會員


查看用戶資訊
Dear All :

MCU = PIC16F15345
RAM = 1024Bytes
如附圖紅色長方框產生的錯誤, static uint8_t buffer[1024] =這樣不行!!!

謝謝.

Attach file:



jpg  螢幕擷取畫面 2021-10-25 084242.jpg (206.10 KB)
3751_6175ff02d6635.jpg 1387X803 px

發表於: 2021/10/25 8:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------