Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
stm32:peripherals:gpio_output [2016/02/25 08:11] feurstm32:peripherals:gpio_output [2022/12/28 08:17] (current) ruan
Line 1: Line 1:
 ====== General Purpose Output ====== ====== General Purpose Output ======
  
-  * The output buffer is enabled (open drain or push-pull).+  * The [[#OTYPER|output buffer]] is enabled (open drain or push-pull).
   * The Schmitt trigger input is active.   * The Schmitt trigger input is active.
-  * The pull-up and -down resistors are active, according to [[gpio#registers|PUPDR]].+  * The pull-up and -down resistors are active, according to [[#registers|PUPDR]].
   * Input data is sampled every AHB clock.   * Input data is sampled every AHB clock.
   * Input data register holds I/O state.   * Input data register holds I/O state.
Line 9: Line 9:
  
 \\ {{gpio_output.svg}} \\ \\ \\ {{gpio_output.svg}} \\ \\
 +
 +===== Programming Instructions =====
 +
 +==== Enable Peripheral ====
 +
 +Make sure the peripheral is enabled:
 +  * Enable GPIOx in ''RCC->AHBENR[0]''.
 +
 +==== Setup output mode ====
 +
 +Configure the MODE and PUPDR as well as the output type and speed register, \\ for every pin that should act as digital output:
 +  * Write ''0x01'' to the corresponding fields in ''GPIOx->MODE''.
 +  * Configure pull-up / -down in ''GPIOx->PUPDR''.
 +  * Configure output type in ''GPIOx->OTYPER''. \\ (in conjunction with ''GPIOx->PUPDR'')
 +  * Configure output speed in ''GPIOx->OSPEEDR''.
 +\\
  
 ===== Configuration Registers ===== ===== Configuration Registers =====
  
-==== MODER Mode register ====+==== GPIOx_MODER Port mode register ====
  
 \\ {{gpio_reg_common.svg}} \\ \\ \\ {{gpio_reg_common.svg}} \\ \\
  
-|< 100% 5em >| +|< 100% 5em 5em >| 
-|01|Output mode (reset state)|+|Pin x|01|Output mode|
  
-==== PUPDR Push-up / pull-down register ====+==== GPIOx_PUPDR Port pull-up / pull-down register ====
  
 \\ {{gpio_reg_common.svg}} \\ \\ \\ {{gpio_reg_common.svg}} \\ \\
  
-|< 100% 5em >| +|< 100% 5em 5em >| 
-|00|No pull-up, pull-down (reset state)| +|Pin x|00|No pull-up, pull-down (reset state)| 
-|01|Pull-up| +|:::|01|Pull-up| 
-|10|Pull-down|+|:::|10|Pull-down
 +|:::|11|Reserved|
  
-==== OTYPER Output type register ====+==== GPIOx_OTYPER Port output type register ====
  
 \\ {{gpio_reg_otyper.svg}} \\ \\ \\ {{gpio_reg_otyper.svg}} \\ \\
  
-|< 100% 5em >| +|< 100% 5em 5em >| 
-|0|Output type: push-pull (reset state)| +|Pin x|0|Output type: push-pull (reset state)| 
-|1|Output type: open-drain|+|:::|1|Output type: open-drain|
  
-==== OSPEEDR Output speed register ====+==== GPIOx_OSPEEDR Port output speed register ====
  
 \\ {{gpio_reg_common.svg}} \\ \\ \\ {{gpio_reg_common.svg}} \\ \\
  
-|< 100% 5em >| +|< 100% 5em 5em >| 
-|00|Speed: 2 MHz (reset state)| +|Pin x|00|Speed: 2 MHz (reset state)| 
-|01|Speed: 10 MHz| +|:::|01|Speed: 10 MHz| 
-|10|Speed: 50 MHz| +|:::|10|Speed: 50 MHz| 
-|11|Speed: 100 MHz|+|:::|11|Speed: 100 MHz|
  
 ===== Data Registers ===== ===== Data Registers =====
  
-==== ODR Output data register ====+==== GPIOx_ODR Port output data register ====
  
 \\ {{gpio_reg_odr.svg}} \\ \\ \\ {{gpio_reg_odr.svg}} \\ \\
  
-==== BSRR - Bit set / reset register ====+|< 100% 5em 5em >| 
 +|ODx|0|Clear/reset pin x| 
 +|:::|1|Set pin x|
  
-\\ {{gpio_reg_bsrr.svg}} \\ \\+==== GPIOx_BSRR Port bit set / reset register ====
  
-|< 100% 5em >| +\\ {{gpio_reg_bsrr.svg}} \\ \\
-|BSx|Set pin x| +
-|BRx|Clear/reset pin x|+
  
-===== Legend =====+|< 100% 5em 5em >| 
 +|BSx|0|No effect| 
 +|:::|1|Set pin x| 
 +|BRx|0|No effext| 
 +|:::|1|Clear/reset pin x|
  
-\\ {{legende.svg}} \\ \\ 
  • stm32/peripherals/gpio_output.1456387895.txt.gz
  • Last modified: 2016/02/25 08:11
  • by feur