• nrf52832 PWM配置


    1. PWM使用时sdk_config.h文件中配置如下:
    2. #define PWM_ENABLED 1
    3. #define PWM0_ENABLED 1
    4. #define NRFX_PWM_ENABLED 1
    5. #define NRFX_PWM0_ENABLED 0

     sdk_config.h 文件中添加下列配置

    1. // NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver
    2. //==========================================================
    3. #ifndef NRFX_PWM_ENABLED
    4. #define NRFX_PWM_ENABLED 0
    5. #endif
    6. // NRFX_PWM0_ENABLED - Enable PWM0 instance
    7. #ifndef NRFX_PWM0_ENABLED
    8. #define NRFX_PWM0_ENABLED 0
    9. #endif
    10. // NRFX_PWM1_ENABLED - Enable PWM1 instance
    11. #ifndef NRFX_PWM1_ENABLED
    12. #define NRFX_PWM1_ENABLED 0
    13. #endif
    14. // NRFX_PWM2_ENABLED - Enable PWM2 instance
    15. #ifndef NRFX_PWM2_ENABLED
    16. #define NRFX_PWM2_ENABLED 0
    17. #endif
    18. // NRFX_PWM3_ENABLED - Enable PWM3 instance
    19. #ifndef NRFX_PWM3_ENABLED
    20. #define NRFX_PWM3_ENABLED 0
    21. #endif
    22. // NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31>
    23. #ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN
    24. #define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31
    25. #endif
    26. // NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31>
    27. #ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN
    28. #define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31
    29. #endif
    30. // NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31>
    31. #ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN
    32. #define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31
    33. #endif
    34. // NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31>
    35. #ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN
    36. #define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31
    37. #endif
    38. // NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock
    39. // <0=> 16 MHz
    40. // <1=> 8 MHz
    41. // <2=> 4 MHz
    42. // <3=> 2 MHz
    43. // <4=> 1 MHz
    44. // <5=> 500 kHz
    45. // <6=> 250 kHz
    46. // <7=> 125 kHz
    47. #ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK
    48. #define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4
    49. #endif
    50. // NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode
    51. // <0=> Up
    52. // <1=> Up and Down
    53. #ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE
    54. #define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0
    55. #endif
    56. // NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value
    57. #ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE
    58. #define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000
    59. #endif
    60. // NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode
    61. // <0=> Common
    62. // <1=> Grouped
    63. // <2=> Individual
    64. // <3=> Waveform
    65. #ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE
    66. #define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0
    67. #endif
    68. // NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode
    69. // <0=> Auto
    70. // <1=> Triggered
    71. #ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE
    72. #define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0
    73. #endif
    74. // NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
    75. // <0=> 0 (highest)
    76. // <1=> 1
    77. // <2=> 2
    78. // <3=> 3
    79. // <4=> 4
    80. // <5=> 5
    81. // <6=> 6
    82. // <7=> 7
    83. #ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY
    84. #define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6
    85. #endif
    86. // NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module.
    87. //==========================================================
    88. #ifndef NRFX_PWM_CONFIG_LOG_ENABLED
    89. #define NRFX_PWM_CONFIG_LOG_ENABLED 0
    90. #endif
    91. // NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level
    92. // <0=> Off
    93. // <1=> Error
    94. // <2=> Warning
    95. // <3=> Info
    96. // <4=> Debug
    97. #ifndef NRFX_PWM_CONFIG_LOG_LEVEL
    98. #define NRFX_PWM_CONFIG_LOG_LEVEL 3
    99. #endif
    100. // NRFX_PWM_CONFIG_INFO_COLOR - ANSI escape code prefix.
    101. // <0=> Default
    102. // <1=> Black
    103. // <2=> Red
    104. // <3=> Green
    105. // <4=> Yellow
    106. // <5=> Blue
    107. // <6=> Magenta
    108. // <7=> Cyan
    109. // <8=> White
    110. #ifndef NRFX_PWM_CONFIG_INFO_COLOR
    111. #define NRFX_PWM_CONFIG_INFO_COLOR 0
    112. #endif
    113. // NRFX_PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix.
    114. // <0=> Default
    115. // <1=> Black
    116. // <2=> Red
    117. // <3=> Green
    118. // <4=> Yellow
    119. // <5=> Blue
    120. // <6=> Magenta
    121. // <7=> Cyan
    122. // <8=> White
    123. #ifndef NRFX_PWM_CONFIG_DEBUG_COLOR
    124. #define NRFX_PWM_CONFIG_DEBUG_COLOR 0
    125. #endif
    126. //
    127. //

     添加\modules\nrfx\drivers\src\nrfx_pwm.c 文件中到nRF_drivers工程文件夹

    添加库文件 \integration\nrfx\legacy\nrf_drv_pwm.h

    以及添加库引用  #include "nrf_drv_pwm.h"

    编译报错:error:  #20: identifier "NRFX_PWM0_INST_IDX" is undefined

    解决办法: sdk_config.h文件中找到 PWM0_ENABLED  设置为1即可

    编译报错: Undefined symbol nrfx_pwm_init (referred from rgb3528.o).

    解决办法:sdk_config.h文件中找到 PWM_ENABLED 设置为1 

  • 相关阅读:
    PaddleX数据集规范
    Swagger enum 最佳实践:深度剖析与应用指南
    企业大数据分析的趋势是怎样
    深度学习制作自己的数据集—为数据集打上标签保存为txt文件,并进行划分和加载数据集
    【算法】Inclusion of a Shuffled String Into another String
    Linux日志管理
    如何入门搭建Python的开发环境
    拖死项目的不是团队,可能是失败的管理
    一个年薪20万软件测试工程师都具备的能力,你有吗?
    spring framework 5.2文档 - 控制反转 IoC 容器
  • 原文地址:https://blog.csdn.net/MyLovelyJay/article/details/134007538