초보의 아웅다웅 설계하기/Neowine_Dalpu

Keil에서 함수를 RAM상에 올려서 사용하기

로망와니 2020. 3. 20. 13:58

Flash 메모리의 접근 속도가 느릴 경우 자주 쓰는 함수들을 RAM에 올려놓고 쓰는 것이 속도에 대한 방안이 될 수 있을 것 같습니다.(실제로 해보지는 않았습니다... 저는 다른 용도때문에 올렸습니다.)

 

우선 Keil의 프로젝트 옵션에서 Linker항목에서 Use Memory Layout from Target Dialog의 체크를 풀어서 

Scatter File 파일을 사용하게끔 설정하여야 합니다. Keil을 사용하면 기본구조는 나와있기때문에 그다지 어렵지 않게 사용할 수 있습니다.

 

ramfunction.c라는 파일에 foo 섹션을 만들어(예제 사이트 참조) 사용하였고 sct 파일에 섹션의 위치를 설정해주었습니다.

그리고 아래처럼 함수의 위치를 main 함수에서 불러주었습니다.

printf("Func Location : %X\r\n", &add1);

결과가 아래와 같이 나오네요.

Func Location : 20000001

 

 

 

 

#pragma arm section code = "foo"

int add1(int x) // in foo (code part of region)

{

return x+1;

}

#pragma arm section code

 

 

 

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x00000000 0x00010000  {    ; load region size_region
  ER_IROM1 0x00000000 0x00010000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x20000000 0x00008000  {  ; RW data
   .ANY (+RW +ZI)
   ramfunction.o (foo)
  }
}

 

 

http://www.keil.com/support/man/docs/armlink/armlink_pge1362066000009.htm

 

Linker User Guide: Placement of code and data with __attribute__((section("name")))

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data. Accept and hide this message

www.keil.com

 

http://www.keil.com/support/man/docs/armcc/armcc_chr1359124985290.htm

 

Compiler User Guide: #pragma arm section [section_type_list]

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data. Accept and hide this message

www.keil.com