[완료]외부램에 배열변수 지정하기..

kds4715의 이미지

안녕하세요. C언어를 시작한지 얼마 안되는 초보입니다.

#define U0txbuf(point) *(volatile char*) (ESRAM_BASE +point)

외부램을 엑세스할 때 위와 같은 방법 말고 배열변수를 사용해서 엑세스할 수 있는 방법이 있는지요?

변수를 지정할 때 그 변수를 특정 번지에 고정하는 방법이 있을듯 한데 어떤방법이 있을까요?

어셈에서 org 와 비슷한...

bushi의 이미지

volatile char *U0txbuf = (volatile char*)(ESRAM_BASE+TXBUF_OFFSET);
 
printf("%p %p\n", &U0txbuf[0], &U0txbuf[1]);
 
printf("%02x %02x\n", U0txbuf[0], U0txbuf[1]);
printf("%02x %02x\n", *(U0txbuf+0), *(U0txbuf+1));

kds4715의 이미지

답변 감사드립니다.

배열의 크기도 지정하고싶은데 그럴경우 어떻게 해야하는지요?

여러개의 배열을 지정하고 그 배열들이 외부메모리에 순서대로 나열이 되어야 하는데..

님께 알려주신 방법은 OFFSET 값을 앞에서 지정한 배열의 크기만큼 지정해줘야 하는 불편함이 좀 있겠군요.

내부램에 배열을 지정하듯이 배열의 크기만으로 외부램에 쭈~욱 나열하고싶습니다.

char U0buf[300];
int Nbuf[1024];
이런식으로 외부램에 계속 나열해서...

아직 개념이 어리버리합니다. 감사합니다.

bushi의 이미지

struct 를 사용하세요.

bushi의 이미지

부실했습니다. 대강의 얼개는...

typedef struct __attribute((packed)) my_data_s {
    char a[100];
    int b[100];
} data_t;
 
volatile data_t *sram_data = (volatile data_t *)(SRAM_BASE+DATA_OFFSET);
 
printf("%c\n", sram_data->a[10]);
printf("%d\n", sram_data->b[20]);

align 에 자신있다면 __attribute((packed)) 를 사용하지 않으셔도 되고,
필요한데 gcc 가 아니라면 해당 컴파일러의 매뉴얼을 보세요.

ed.netdiver의 이미지

char U0buf[300];
int buf[1024];
만 정의된 c file을 만드시고 locater 파일에서 해당 object file의 ZI나 BSS영역(초기화여부에 따라)을 원하시는 ext ram영역에 잡으시면 되겠네요.

--------------------------------------------------------------------------------
\(´∇`)ノ \(´∇`)ノ \(´∇`)ノ \(´∇`)ノ
def ed():neTdiVeR in range(thEeArTh)

--------------------------------------------------------------------------------
\(´∇`)ノ \(´∇`)ノ \(´∇`)ノ \(´∇`)ノ
def ed():neTdiVeR in range(thEeArTh)

kds4715의 이미지

답변 주신분들 감사합니다.
한참 부족한데 앞으로 더욱 열심히 해야겠습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.