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


Browsing this Thread:   1 Anonymous Users




« 1 (2)


Re: ATSAME54P20A--定址
#3
管理員
管理員


查看用戶資訊
你好, 這個部分有兩個問題
1. 原先的寫法
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000000)));
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000000 + CAN0_MESSAGE_RAM_CONFIG_SIZE)));

CAN0_MESSAGE_RAM_CONFIG_SIZE = 56
Can1MessageRAM 的 address 因為aligned(32)的關係, 會等於address(0x20000000 + 32), 導致 Can1MessageRAM 記憶體位址去疊到Can0MessageRAM
Can0MessageRAM @ 0x20000000, size 56 (0x20000000 ~ 0x20000038)
Can1MessageRAM @ 0x20000020, size 56
所以請拿掉aligned(32)或是將Can1MessageRAM的定址取為32的倍數
最後
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000020)));
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000020 + ((CAN0_MESSAGE_RAM_CONFIG_SIZE%32)+1)*32)));

2. 另外一個問題是上面你看到, 起始位置不是在0x20000000而是自0x20000020開始, 你看MAP file時會發現前面0x20000000開始有保留一小塊區塊, 這部分需要避開
.bss 0x20000000 0x10 16 Uninitialized data
這部分會因為你用到的Harmony Module而不同, 看起來是因為SYS_Tick Module拿去用了, 我建的專案佔了0x0C, 你的佔了0x10, 因為aligned(32)所以我將起始位置移到0x20000020

發表於: 2020/5/22 11:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#2
新會員
新會員


查看用戶資訊
假如我將定址改到其他位址。
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20010000)));                                 

uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20010000 CAN0_MESSAGE_RAM_CONFIG_SIZE)));

確認map檔內容無誤。
_0c5519485ec73812%1                 
0x20010060       0x60  
_0c5519485ec73812                
 0x20010060       0x60 build
/sam_e54_xpro/production/_ext/1360937237/main_e54.o  
               
0x20010060                Can1MessageRAM  
_0c5518f05ec73812
%2                 
0x20010000       0x60 
 _0c5518f05ec73812 

0x20010000       0x60 build
/sam_e54_xpro/production/_ext/1360937237/main_e54.o                 
0x20010000                Can0MessageRAM


RAM Data
-Memory Usage
section                    address  length 
[bytes]      (dec)  Description
-------                 ----------  -------------------------  -----------
.
bss                    0x20000000           0x10          16  Uninitialized data 
.data.impure_data       0x20000010          0x418        1048   
.data.__malloc_av_      0x20000428          0x408        1032   
.data.__global_locale   0x20000830          0x16c         364   
.bss.message            0x2000099c           0x40          64   
.bss.rx_message         0x200009dc           0x40          64   
.bss.can1RxMsg          0x20000a1c           0x30          48   
.bss.can0RxMsg          0x20000a4c           0x30          48   
.bss.can1Obj            0x20000a7c           0x28          40   
.bss.can0Obj            0x20000aa4           0x28          40   
.bss.__malloc_current_m 0x20000acc           0x28          40   
.bss.can1CallbackObj    0x20000af4           0x20          32   
.bss.can0CallbackObj    0x20000b14           0x20          32   
.bss                    0x20000b34           0x1c          28  Uninitialized data 
.bss.messageID          0x20000b50            0x4           4   
.bss.rx_messageID       0x20000b54            0x4           4   
.bss.xferContext        0x20000b58            0x4           4   
.data._impure_ptr       0x20000b5c            0x4           4   
.bss.__malloc_max_sbrke 0x20000b60            0x4           4   
.bss.__malloc_max_total 0x20000b64            0x4           4   
.bss.__malloc_top_pad   0x20000b68            0x4           4   
.data.__malloc_sbrk_bas 0x20000b6c            0x4           4   
.data.__malloc_trim_thr 0x20000b70            0x4           4   
.bss                    0x20000b74            0x4           4  Uninitialized data 
.bss.timestamp          0x20000b78            0x2           2   
.bss.messageMarker.8529 0x20000b7a            0x1           1   
.bss.loop_count         0x20000b7b            0x1           1   
.bss.messageLength      0x20000b7c            0x1           1   
.bss.rx_messageLength   0x20000b7d            0x1           1   
.data.state             0x20000b7e            0x1           1   
_0c63b8f05ec7381b       0x20010000           0x60          96   
_0c63b9485ec7381b       0x20010060           0x60          96   
         Total RAM used  
:       0xc3f        3135  1.2of 0x40000
        
--------------------------------------------------------------------------
            
Total Data Memory used  :       0xc3f        3135  1.2of 0x40000
        
--------------------------------------------------------------------------

但是通訊會有問題,data傳送內容為0x00,ID也是為0x00,
當然不定址就不會有這樣的狀況。
因為有特殊規劃,所以需要定址。
有無方式可以排除此狀況。

發表於: 2020/5/22 10:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


ATSAME54P20A--定址
#1
新會員
新會員


查看用戶資訊
想請問為何使用絕對定址但出現錯誤?
#include <stddef.h>      // Defines NULL
#include <stdbool.h>     // Defines true
#include <stdlib.h>      // Defines EXIT_FAILURE
#include "definitions.h" // SYS function prototypes
//=========================================================================================================================================================
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20000000)));                                
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20000000 CAN0_MESSAGE_RAM_CONFIG_SIZE))); 
 
int main(void)
{
    
/* Initialize all modules */
    
SYS_Initialize(NULL);
    
SYSTICK_TimerStart();
    
LED0_Set();
    
SYSTICK_DelayMs(100);

    
/* Set Message RAM Configuration */
    
CAN0_MessageRAMConfigSet(Can0MessageRAM);
    
CAN1_MessageRAMConfigSet(Can1MessageRAM);
    
CAN1_RxCallbackRegister(APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_RECEIVECAN_MSG_ATTR_RX_FIFO0);
    
CAN1_TxCallbackRegister(APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_TRANSMIT);
    
display_menu();
    while (
true)
    {
     }
}

//不知為何0x20000000及 CAN0_MESSAGE_RAM_CONFIG_SIZE中間的加號無法顯示


以下為compiler的錯誤訊息
Link ErrorCould not allocate section '_0c4b18f05ec644c4' at 0x20000000  
Link Error
Could not allocate data memory 
collect2
.exeerrorld returned 255 exit status 
make
[2]: *** [nbproject/Makefile-sam_e54_xpro.mk:336dist/sam_e54_xpro/production/sam_e54_xpro.X.production.hexError 255 
make
[1]: *** [nbproject/Makefile-sam_e54_xpro.mk:94: .build-confError 2 
make
: *** [nbproject/Makefile-impl.mk:39: .build-implError 2  
BUILD FAILED 
(exit value 2total time3s)


有無方法可以排除,感謝。

發表於: 2020/5/21 17:34
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... ]

教育訓練中心

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