[해결]PXA255 매뉴얼에 오타가 있는것 같아요. 헷갈려 죽겠어요.

yo-tteum의 이미지

제가 간단한 시리얼 에코 기능을 구현하려고 하는데요. 처음에 GPIO 설정하는 부분에 설명이 너무 좀 이상해서
질문 드려요.
To select any of the alternate
functions, the GPDR register must configure the GPIO to be an input.
이 문장을 읽으면 부가 기능을 설정하기 위해서는 GPIO를 input으로 하라고 나오잖아요. 그런데 다음문장.
Similarly, only GPIOs
configured as outputs by the GPDR can be configured for alternate output functions.
여기서는 alternate output function으로 설정하기 위해서는 output으로 먼저 설정되어 있어야 한다고 하잖아요.
문장 시작도 유사하게,, 로 시작하는데 그럼 첫 문장은
To select any of the alternate
functions, the GPDR register must configure the GPIO to be an input
이게 아니고
To select any of the alternate input
functions, the GPDR register must configure the GPIO to be an input
이라고 input이 추가되어야 하는 것 아닌가요? 이것때문에 송 수신 핀 둘다 input으로 설정해둔 상태에서
alternate function을 설정해야 하는지 헷갈리네요. 생전 처음 해보는건데 매뉴얼이 너무 헷갈려서요.

확답 주실 수 있으신분 댓글 부탁드립니다. ㅠ

-----------------------------------------------------------------------------------------------
4.1.3.6GPIO Alternate Function Register (GAFR0_L, GAFR0_U, GAFR1_L, GAFR1_U, GAFR2_L, GAFR2_U)
GAFR0_L, GAFR0_U, GAFR1_L, GAFR1_U, GAFR2_L, GAFR2_U, shown in Table 4-24,
Table 4-25, Table 4-26, Table 4-27, Table 4-28, and Table 4-29, contain select bits that correspond
to the 85 GPIO pins. Each GPIO can be configured to be either a generic GPIO pin, one of 3
alternate input functions, or one of 3 alternate output functions. To select any of the alternate
functions, the GPDR register must configure the GPIO to be an input. Similarly, only GPIOs
configured as outputs by the GPDR can be configured for alternate output functions. Each GPIO
pin has a pair of bits assigned to it whose values determine which function (normal GPIO, alternate
function 1, alternate function 2 or alternate function 3) the GPIO performs. The function selected is
determined by writing the GAFR bit pair as below:
• “00” indicates normal GPIO function
• “01” selects alternate input function 1 (ALT_FN_1_IN) or alternate output function 1
(ALT_FN_1_OUT)
• “10” selects alternate input function 2 (ALT_FN_2_IN) or alternate output function 2
(ALT_FN_2_OUT)
• “11” selects alternate input function 3 (ALT_FN_3_IN) or alternate output function 3
(ALT_FN_3_OUT)

File attachments: 
첨부파일 크기
PDF icon PXA255 Developer's Manual.pdf5.16 MB
drinkme의 이미지

Figure 4.1과 같이 보면 이해가 쉬울겁니다.

즉슨, gpio가 아니라, 일반적인 경우에서 alternate로 사용할 경우,
direction을 input으로 해라. 만약, alternate가 output일 경우에만, direction을 output을 할 수 있다.

설명이 조금 이상하게 들리더라도...
보통 이렇게 많이 합니다.
alternate가 input인지 output인 잘 모르는(?) 상태에서 alternate 설정 이전에는 우선 gpio를 input으로 놓습니다. (또는 그래야만 합니다).
안그러면 안그러면 경우에 따라서는 gpio low로 전류가 몽땅 들어가 버릴 수도 있어서...

yo-tteum의 이미지

감사합니다

bushi의 이미지

alternate 는 alternate 일 뿐 input/ouput 을 구분해서 따지는 게 의미없습니다.
예를 들어 I2C data 핀은 bi-direction 이고,
I2C 컨트롤러의 내부 state machine 에 따라 수시로 그 속성이 바뀝니다.

GPIO input 이 default 라는 것은 꼭 alternate 설정 때만 유념할 것이 아니라 모든 경우에 적용됩니다.
POR 때 모든 GPIO 는 input 상태로 되어 있습니다.
아시다시피 input 설정의 핀은 hi-Z 상태라 회로에 능동적인 영향을 주지 않습니다.
(source 도 아니고 sink 도 아닌 상태기 때문에 연결된 외부 장치에 능동적인 잡신호가 인가되지 않습니다.)

이게 별거 아닌 것 같아보여도, 꽤 심각한 문제가 발생할 수 있습니다.
s3c2410 에 SRAM 을 붙이다 애먹은 적이 있었습니다.
chip select 기능으로 전환할 수 있는 GPIO 가 있는데, 이놈이 CPU POR 중간에 잠시 output low 상태가 되는 순간(sink)이 있더군요.
SRAM 의 특정 영역에 항상 듣도보도 못한 괴상한 데이타가 기록되곤 했습니다.
결국 SRAM 을 물리는 뱅크를 바꾸고서야 증상이 없어졌더랬습니다.
(alternative chip select 가 아니라 native chip select 를 사용하는..)

GPIO 를 alt.function 으로 바꾸거나 alt.function 을 GPIO 로 바꿀 땐
외부회로에 영향을 주지않도록, 내부컨트롤러에 영향을 주지 않도록 전기적인 고려를 해서 순서를 정하세요.
매뉴얼의 해당내용은 이런 일반적인 사항을 설명하는 것일 뿐 PXA255의 특별한 어떤 것을 설명하는 것은 아닙니다.

+

리눅스에서라면, generic gpio lib 의 구현부를 보시면 이해가 좀 쉬울 겁니다.
GPIO input 이었던 핀을 GPIO output 으로 설정하는 것들을 보면
output level을 먼저 설정한 뒤에 direction 을 바꾸도록 되어 있습니다.
단순한 GPIO direction 전환에서조차도 외부회로에 끼치는 영향을 고려해야 하도록 배려(강제)하고 있습니다.

OTL

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.