你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

使用mbed开发如何设置时钟频率

[复制链接]
hjl240 提问时间:2014-11-27 17:39 /
使用mbed开发st公司提供的开发板很方便,但是在头文件里没有找到如何设置系统的时钟频率的头文件,该怎么设置呢?


mebd.png


收藏 评论4 发布时间:2014-11-27 17:39

举报

4个回答
hjl240 回答时间:2014-11-27 18:12:54
还有如何设置AD的采样速率?头文件里好像都没有说
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *     http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_ANALOGIN_H
  17. #define MBED_ANALOGIN_H

  18. #include "platform.h"

  19. #if DEVICE_ANALOGIN

  20. #include "analogin_api.h"

  21. namespace mbed {

  22. /** An analog input, used for reading the voltage on a pin
  23. *
  24. * Example:
  25. * @code
  26. * // Print messages when the AnalogIn is greater than 50%
  27. *
  28. * #include "mbed.h"
  29. *
  30. * AnalogIn temperature(p20);
  31. *
  32. * int main() {
  33. *     while(1) {
  34. *         if(temperature > 0.5) {
  35. *             printf("Too hot! (%f)", temperature.read());
  36. *         }
  37. *     }
  38. * }
  39. * @endcode
  40. */
  41. class AnalogIn {

  42. public:

  43.     /** Create an AnalogIn, connected to the specified pin
  44.      *
  45.      * @param pin AnalogIn pin to connect to
  46.      * @param name (optional) A string to identify the object
  47.      */
  48.     AnalogIn(PinName pin) {
  49.         analogin_init(&_adc, pin);
  50.     }

  51.     /** Read the input voltage, represented as a float in the range [0.0, 1.0]
  52.      *
  53.      * @returns A floating-point value representing the current input voltage, measured as a percentage
  54.      */
  55.     float read() {
  56.         return analogin_read(&_adc);
  57.     }

  58.     /** Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
  59.      *
  60.      * @returns
  61.      *   16-bit unsigned short representing the current input voltage, normalised to a 16-bit value
  62.      */
  63.     unsigned short read_u16() {
  64.         return analogin_read_u16(&_adc);
  65.     }

  66. #ifdef MBED_OPERATORS
  67.     /** An operator shorthand for read()
  68.      *
  69.      * The float() operator can be used as a shorthand for read() to simplify common code sequences
  70.      *
  71.      * Example:
  72.      * @code
  73.      * float x = volume.read();
  74.      * float x = volume;
  75.      *
  76.      * if(volume.read() > 0.25) { ... }
  77.      * if(volume > 0.25) { ... }
  78.      * @endcode
  79.      */
  80.     operator float() {
  81.         return read();
  82.     }
  83. #endif

  84. protected:
  85.     analogin_t _adc;
  86. };

  87. } // namespace mbed

  88. #endif

  89. #endif
复制代码
晓枫VS枯叶 回答时间:2014-11-27 20:26:55
在线版的mbed编译器上无法更改 时钟频率等一些列的东西,建议使用离线版中更改 底层文件实现!
hjl240 回答时间:2014-11-27 20:41:54
晓枫VS枯叶 发表于 2014-11-27 20:26
在线版的mbed编译器上无法更改 时钟频率等一些列的东西,建议使用离线版中更改 底层文件实现! ...

离线版指的是keil?
晓枫VS枯叶 回答时间:2014-11-27 20:52:06
现在keil和IAR上都可以编译了,建议使用IAR,编译速度比mdk快一些!

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版