{"id":2764,"date":"2025-07-24T18:18:47","date_gmt":"2025-07-24T17:18:47","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=2764"},"modified":"2025-07-25T14:40:26","modified_gmt":"2025-07-25T13:40:26","slug":"gpio-bcm-2837","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/","title":{"rendered":"GPIO BCM 2837"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\"><strong>Adresses de base des registres GPIO<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Sur le BCM2837, les registres GPIO sont mapp\u00e9s en m\u00e9moire \u00e0 partir de l\u2019adresse de base :<br><strong><code>0x3F000000<\/code><\/strong>&nbsp;(contre&nbsp;<code>0x20000000<\/code>&nbsp;sur le BCM2835).<br>Les registres GPIO occupent une plage de&nbsp;<strong>0x3F200000 \u00e0 0x3F2000B4<\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note<\/strong>&nbsp;:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sur le&nbsp;<strong>Pi 4 (BCM2711)<\/strong>, l\u2019adresse de base devient&nbsp;<strong><code>0xFE000000<\/code><\/strong>.<\/li>\n\n\n\n<li>Toujours v\u00e9rifier le mod\u00e8le avec&nbsp;<code>cat \/proc\/cpuinfo<\/code>.<\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<h1 class=\"wp-block-heading\">Structure des registres GPIO cl\u00e9s<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Chaque registre fait 32 bits (4 octets). Voici les principaux :<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Offset<\/strong><\/td><td><strong>Registre<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>0x00 <\/td><td>GPFSEL0 \u00e0 GPFSEL5<\/td><td>Configuration des broches (entr\u00e9e\/sortie\/fonction alternative).<\/td><\/tr><tr><td>0x1C<\/td><td>GPSET0 \/ GPSET1<\/td><td>Mettre une broche \u00e0 1 (activation).<\/td><\/tr><tr><td>0x28<\/td><td>GPCLR0 \/ GPCLR1<\/td><td>Mettre une broche \u00e0 0 (d\u00e9sactivation).<\/td><\/tr><tr><td>0x34<\/td><td>GPLEV0 \/ GPLEV1<\/td><td> Lire l\u2019\u00e9tat actuel d\u2019une broche (niveau haut\/bas).<\/td><\/tr><tr><td>0x40<\/td><td>GPEDS0 \/ GPEDS1<\/td><td>D\u00e9tection d\u2019\u00e9v\u00e9nement (front montant\/descendant).<\/td><\/tr><tr><td>0x7E<\/td><td>GPPUD<\/td><td>Configuration des r\u00e9sistances de pull-up\/pull-down.<\/td><\/tr><tr><td>0x94<\/td><td>GPPUDCLK0\/GPPUDCLK1<\/td><td>0x94 GPPUDCLK0\/GPPUDCLK1 Activation du pull-up\/pull-down pour une broche sp\u00e9cifique.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">offset pour acc\u00e9der aux registres internes<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>D\u00e9tail des registres de fonction (GPFSEL)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Chaque registre&nbsp;<code>GPFSEL0<\/code>&nbsp;\u00e0&nbsp;<code>GPFSEL5<\/code>&nbsp;contr\u00f4le&nbsp;<strong>10 broches<\/strong>&nbsp;(3 bits par broche) :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>000<\/strong>&nbsp;: Entr\u00e9e.<\/li>\n\n\n\n<li><strong>001<\/strong>&nbsp;: Sortie.<\/li>\n\n\n\n<li><strong>010 \u00e0 111<\/strong>&nbsp;: Fonction alternative (UART, SPI, I2C, etc.).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Exemple<\/strong>&nbsp;: Configurer la&nbsp;<strong>GPIO17<\/strong>&nbsp;(broche 11 du header) en sortie :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>La GPIO17 est g\u00e9r\u00e9e par&nbsp;<code>GPFSEL1<\/code>&nbsp;(offset&nbsp;<code>0x04<\/code>).<\/li>\n\n\n\n<li>Bits&nbsp;<strong>21-23<\/strong>&nbsp;dans&nbsp;<code>GPFSEL1<\/code>&nbsp;doivent \u00eatre&nbsp;<code>001<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ En C (acc\u00e8s direct m\u00e9moire) :\nvolatile unsigned int* gpio = (unsigned int*)0x3F200000;\n*(gpio + 1) |= (1 &lt;&lt; 21); \/\/ GPFSEL1&#91;21:23] = 001<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Activation\/d\u00e9sactivation des broches (GPSET\/GPCLR)<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>GPSET0<\/strong>&nbsp;(offset&nbsp;<code>0x1C<\/code>) : \u00c9crire&nbsp;<code>1<\/code>&nbsp;pour activer une broche.<\/li>\n\n\n\n<li><strong>GPCLR0<\/strong>&nbsp;(offset&nbsp;<code>0x28<\/code>) : \u00c9crire&nbsp;<code>1<\/code>&nbsp;pour d\u00e9sactiver une broche.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Exemple<\/strong>&nbsp;: Allumer la&nbsp;<strong>GPIO17<\/strong>&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*(gpio + 7) = (1 &lt;&lt; 17); \/\/ GPSET0&#91;17] = 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u00c9teindre la&nbsp;<strong>GPIO17<\/strong>&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*(gpio + 10) = (1 &lt;&lt; 17); \/\/ GPCLR0&#91;17] = 1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Lecture d\u2019une broche (GPLEV)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pour lire l\u2019\u00e9tat de la&nbsp;<strong>GPIO17<\/strong>&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int state = (*(gpio + 13) &gt;&gt; 17) &amp; 1; \/\/ GPLEV0&#91;17]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Pull-up\/pull-down (GPPUD et GPPUDCLK)<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u00c9crire la configuration dans&nbsp;<code>GPPUD<\/code>&nbsp;(offset&nbsp;<code>0x94<\/code>) :<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>0x00<\/code>&nbsp;: D\u00e9sactiver.<\/li>\n\n\n\n<li><code>0x01<\/code>&nbsp;: Pull-down.<\/li>\n\n\n\n<li><code>0x02<\/code>&nbsp;: Pull-up.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Activer la configuration pour une broche via&nbsp;<code>GPPUDCLK0<\/code>&nbsp;(offset&nbsp;<code>0x98<\/code>).<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>*(gpio + 37) = 0x02;       \/\/ GPPUD = pull-up\ndelay(150);                \/\/ Attendre 150 cycles\n*(gpio + 38) = (1 &lt;&lt; 17);  \/\/ GPPUDCLK0&#91;17] = 1\ndelay(150);\n*(gpio + 37) = 0x00;       \/\/ R\u00e9initialiser GPPUD\n*(gpio + 38) = 0x00;       \/\/ R\u00e9initialiser GPPUDCLK0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Mapping des broches (Header 40 broches)<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\"><strong>Broche<\/strong><\/th><th class=\"has-text-align-left\" data-align=\"left\"><strong>GPIO<\/strong><\/th><th class=\"has-text-align-left\" data-align=\"left\"><strong>Fonction alternative<\/strong><\/th><\/tr><\/thead><tbody><tr><td>11<\/td><td>GPIO17<\/td><td>G\u00e9n\u00e9rique (sortie LED).<\/td><\/tr><tr><td>12<\/td><td>GPIO18<\/td><td>PWM0.<\/td><\/tr><tr><td>19<\/td><td>GPIO10<\/td><td>SPI0_MOSI.<\/td><\/tr><tr><td>23<\/td><td>GPIO11<\/td><td>SPI0_SCLK.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Exemple complet en C (sans librairie)<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;fcntl.h>\n#include &lt;sys\/mman.h>\n#include &lt;unistd.h>\n\n\/\/ Adresses pour Raspberry Pi (\u00e0 ajuster selon mod\u00e8le)\n#define GPIO_BASE 0xFE200000 \/\/ RPi 4 (BCM2711)\n\/\/ #define GPIO_BASE 0x3F200000 \/\/ RPi 2\/3\n#define PAGE_SIZE 4096\n#define BLOCK_SIZE 4096\n\n\/\/ Registres GPIO\n#define GPFSEL0 0x00 \/\/ Fonction Select 0\n#define GPSET0  0x1C \/\/ Set Output\n#define GPCLR0  0x28 \/\/ Clear Output\n\nvolatile unsigned int *gpio;\n\nvoid init_gpio() {\n    int fd = open(\"\/dev\/gpiomem\", O_RDWR | O_SYNC);\n    if (fd &lt; 0) {\n        perror(\"\u00c9chec de l'ouverture de \/dev\/gpiomem\");\n        exit(1);\n    }\n\n    gpio = (volatile unsigned int *)mmap(\n        NULL,\n        BLOCK_SIZE,\n        PROT_READ | PROT_WRITE,\n        MAP_SHARED,\n        fd,\n        GPIO_BASE\n    );\n    close(fd);\n\n    if (gpio == MAP_FAILED) {\n        perror(\"\u00c9chec du mmap\");\n        exit(1);\n    }\n}\n\nvoid set_gpio_output(int pin) {\n    int reg = pin \/ 10;\n    int shift = (pin % 10) * 3;\n    gpio&#91;reg] = (gpio&#91;reg] &amp; ~(7 &lt;&lt; shift)) | (1 &lt;&lt; shift);\n}\n\nint main() {\n    int led_pin = 17; \/\/ GPIO17 (broche physique 11)\n\n    init_gpio();\n    set_gpio_output(led_pin);\n\n    while (1) {\n        gpio&#91;GPSET0 \/ 4] = 1 &lt;&lt; led_pin; \/\/ Allume\n        sleep(1);\n        gpio&#91;GPCLR0 \/ 4] = 1 &lt;&lt; led_pin; \/\/ \u00c9teint\n        sleep(1);\n    }\n\n    munmap((void *)gpio, BLOCK_SIZE);\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Pr\u00e9cautions<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Acc\u00e8s root requis<\/strong>&nbsp;: Utiliser&nbsp;<code>\/dev\/mem<\/code>&nbsp;ou&nbsp;<code>\/dev\/gpiomem<\/code>.<\/li>\n\n\n\n<li><strong>Voltage<\/strong>&nbsp;: Les GPIO sont en&nbsp;<strong>3,3 V<\/strong>&nbsp;(ne pas connecter du 5 V directement).<\/li>\n\n\n\n<li><strong>Synchronisation<\/strong>&nbsp;: Toujours v\u00e9rifier les offsets et adresses pour le BCM2837.<\/li>\n<\/ul>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Adresses de base des registres GPIO Sur le BCM2837, les registres GPIO sont mapp\u00e9s en m\u00e9moire \u00e0 partir de l\u2019adresse de base :0x3F000000&nbsp;(contre&nbsp;0x20000000&nbsp;sur le BCM2835).Les registres GPIO occupent une plage [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-2764","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GPIO BCM 2837 - workboot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GPIO BCM 2837 - workboot\" \/>\n<meta property=\"og:description\" content=\"Adresses de base des registres GPIO Sur le BCM2837, les registres GPIO sont mapp\u00e9s en m\u00e9moire \u00e0 partir de l\u2019adresse de base :0x3F000000&nbsp;(contre&nbsp;0x20000000&nbsp;sur le BCM2835).Les registres GPIO occupent une plage [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-25T13:40:26+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/gpio-bcm-2837\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/gpio-bcm-2837\\\/\",\"name\":\"GPIO BCM 2837 - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"datePublished\":\"2025-07-24T17:18:47+00:00\",\"dateModified\":\"2025-07-25T13:40:26+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/gpio-bcm-2837\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"name\":\"workboot\",\"description\":\"Open Source, Open Minds \",\"publisher\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\",\"name\":\"workboot\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"width\":1024,\"height\":950,\"caption\":\"workboot\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GPIO BCM 2837 - workboot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/","og_locale":"fr_FR","og_type":"article","og_title":"GPIO BCM 2837 - workboot","og_description":"Adresses de base des registres GPIO Sur le BCM2837, les registres GPIO sont mapp\u00e9s en m\u00e9moire \u00e0 partir de l\u2019adresse de base :0x3F000000&nbsp;(contre&nbsp;0x20000000&nbsp;sur le BCM2835).Les registres GPIO occupent une plage [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/","og_site_name":"workboot","article_modified_time":"2025-07-25T13:40:26+00:00","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/","url":"https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/","name":"GPIO BCM 2837 - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"datePublished":"2025-07-24T17:18:47+00:00","dateModified":"2025-07-25T13:40:26+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/gpio-bcm-2837\/"]}]},{"@type":"WebSite","@id":"https:\/\/workboot.fr\/ciela\/#website","url":"https:\/\/workboot.fr\/ciela\/","name":"workboot","description":"Open Source, Open Minds ","publisher":{"@id":"https:\/\/workboot.fr\/ciela\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/workboot.fr\/ciela\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/workboot.fr\/ciela\/#organization","name":"workboot","url":"https:\/\/workboot.fr\/ciela\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","width":1024,"height":950,"caption":"workboot"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Adresses de base des registres GPIO Sur le BCM2837, les registres GPIO sont mapp\u00e9s en m\u00e9moire \u00e0 partir de l\u2019adresse de base :0x3F000000&nbsp;(contre&nbsp;0x20000000&nbsp;sur le BCM2835).Les registres GPIO occupent une plage [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=2764"}],"version-history":[{"count":15,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2764\/revisions"}],"predecessor-version":[{"id":2826,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2764\/revisions\/2826"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=2764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}