STM32下的PWM以及DAC练习

一、用STM32F103输出一路PWM波形

1.打开文件

• 打开之前网盘下载的野火资料:
在这里插入图片描述
• 打开,编译构建。
• 之后点击运行,选择分析窗口:
在这里插入图片描述

2.配置

• 第三步设置如下:
在这里插入图片描述
• 当第一步输完后回车在第二步选择Bit.

3.结果

• 之后若没有出现图像,点击ALL即可;波形图如下:
在这里插入图片描述

二、输出2KHZ的正弦波

所需软件:
• 音频编辑工具Audiotion
• UltraEdit
• notepad++
软件均可在官网下载,此处不累赘

1.构建一个周期为2KHZ的正弦波音频信号

• 打开音频编辑工具构建一个音频文件:
在这里插入图片描述
• 选择如下:
在这里插入图片描述

• 点击效果->生成基本音色:
在这里插入图片描述
• 确定形状为正弦,频率为2000:
在这里插入图片描述
• 之后点击确定。
• 导出:
在这里插入图片描述
• 选择文件路径,确保生成文件为wav类型即可。
• 在界面左边选择所创建的文件,打开:
在这里插入图片描述
右图为所输出的正弦波。

2.生成周期点

• 使用软件UltraEdit打开所创建wav文件:
• CTRL+A全选,点击右键选择16进制复制所选视图:
在这里插入图片描述
• 粘贴到新创建的一个记事本:
在这里插入图片描述
• 再次用UltraEdit打开记事本:
• 点击右键选择范围,设置选择:
在这里插入图片描述
CTRL+C复制即可。
• 新建一个记事本,粘贴:
在这里插入图片描述

• 用nodepad++打开该记事本:
• 选择列块编辑:
在这里插入图片描述

• 第一列插入0x之后每列前面插入,0x最后一列后面加,:
在这里插入图片描述
• 完成之后全选复制。

3.运行代码修改

• 打开野火资料:
在这里插入图片描述
• 打开bsp_dac.c文件:
• 将复制的粘贴到const uint16_t Sine12bit[POINT_NUM] 函数下:
在这里插入图片描述
• 如果出现如下问题:应修改上图中函数的周期点数:
在这里插入图片描述

• 此时如还存在以下问题:
在这里插入图片描述
• 是芯片内存不够可打开项目选项:
在这里插入图片描述
• 修改后,编译构建即可。
在这里插入图片描述

4.结果

• 将生成的HEX文件烧录进STM32开发板。
• 将开发板USB连接电脑或者示波器,PA5接探头,GND接地接口。示波器图像如图:

在这里插入图片描述

三、数字音频数据转换为模拟音频波形输出

1.音频截取

• 用audition打开一个音频,截取一段右键存储选区为:
在这里插入图片描述
将采用率和声道以及位深度修改为如上图所示。

2.生成周期点

• 可以仿照上面生成周期点的步骤生成。
• 下面我使用如下软件生成:

软件网盘地址:百度网盘资源
提取码:7egp

在这里插入图片描述
• 步骤如下:(第二步可选择压缩)
在这里插入图片描述
• 点击保存代码,打开后复制即可:
在这里插入图片描述

3.运行结果

• 可将复制的粘贴到第二个实验的工程里面:
在这里插入图片描述
• 出现问题仿照上面修改。
成功后:
在这里插入图片描述
• 将hex文件烧录到开发板。
• 将开发板连接到示波器,示波器探头接PA5结果如下:

在这里插入图片描述
完成。

### PHP Filter Pseudo-Protocol Bypass Techniques and Principles In the context of web application security, understanding how various protocols function is crucial for both developers and attackers. The `php://filter` pseudo-protocol allows reading files after applying filters on them. This feature can be exploited when input validation mechanisms are weak or improperly implemented. The core principle behind exploiting this protocol involves manipulating URLs that use `php://filter`. For instance, an attacker might craft a URL like: ```plaintext http://example.com/vulnerable.php?page=php://filter/read=convert.base64-encode/resource=index.php ``` This request would cause the server to read the contents of `index.php`, encode it using Base64 encoding, and then output the result as part of the response body[^1]. To mitigate such attacks, applications should enforce strict checks on user-supplied data intended to specify file paths or resources. Specifically, disallowing any form of special characters within these inputs helps prevent injection attempts targeting features similar to those provided by `php://filter`. Furthermore, implementing Content Security Policies (CSPs), ensuring proper configuration of HTTP headers, and employing secure coding practices contribute significantly towards safeguarding against vulnerabilities associated with improper handling of untrusted information sources. #### Example Code Demonstrating Potential Exploit Scenario Below demonstrates a simplified scenario where inadequate sanitization leads to potential exploitation via the `php://filter` mechanism: ```php <?php // Vulnerable code snippet demonstrating lack of sufficient input validation. $file = $_GET['file']; readfile($file); ?> ``` An attacker could leverage this weakness through carefully constructed queries designed to manipulate internal operations related to resource loading and processing functions available under PHP's standard library.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值