stc15w wave
1. 定时器和延时
#include "15W4KxxS4.h"
#define FOSC 12000000
#define CLK (65536-FOSC/2/12/1000)
sbit clk=P3^; void clk_wave(void) //1KHZ@12MHz
{ AUXR |= 0x00; //串口1选择定时器2为波特率发生器
T2L = CLK; //设定定时初值
T2H = CLK>>; //设定定时初值
AUXR |= 0x10; //启动定时器2
INT_CLKO=0x04; }
void Delay5ms() //@12.000MHz
{
unsigned char i, j; i = ;
j = ;
do
{
while (--j);
} while (--i);
} int main(void)
{ //clk_wave();
while ()
{
clk=;
Delay5ms();
clk=;
Delay5ms();
};
}
2. 中断
#include "15W4KxxS4.h"
#include "intrins.h" #define uint8 unsigned char
#define uint16 unsigned int //uint8 data temp[100];
uint8 ti = ; sbit clk=P3^; void Timer0Init(void) //500微秒@12.000MHz
{
AUXR &= 0x7F; //定时器时钟12T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x0C; //设置定时初值
TH0 = 0xFE; //设置定时初值
TF0 = ; //清除TF0标志
ET0=;
EA=;
TR0 = ; //定时器0开始计时
} int main(void)
{
Timer0Init();
while ();
} void wave() interrupt
{
if(ti<=)
clk=;
if(ti>&&ti<=)
clk=;
ti++;
ti=ti%;
//clk=!clk;
}
3. 占空比
#include "15W4KxxS4.h"
#include "intrins.h" #define uint8 unsigned char
#define uint16 unsigned int //uint8 data temp[100];
uint8 ti = ; sbit SI=P3^;
sbit CLK=P0^; void Timer0Init(void) //1毫秒@12.000MHz
{
AUXR &= 0x7F; //定时器时钟12T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x18; //设置定时初值
TH0 = 0xFC; //设置定时初值
TF0 = ; //清除TF0标志
ET0=;
EA=;
TR0 = ; //定时器0开始计时
}
int main(void)
{
ti=;
Timer0Init();
while ();
} void wave() interrupt
{
ti++;
if(ti==) //低电平循环次数,高电平为两者之差
CLK=;
else if(ti==) //总循环次数
{
CLK=;
ti=;
} }
4. 两束波,相位延迟
#include "15W4KxxS4.h"
#include "intrins.h" #define uint8 unsigned char
#define uint16 unsigned int //uint8 data temp[100];
uint8 ti = ; sbit CLK=P3^;
sbit SI=P0^; void Timer0Init(void) //1毫秒@12.000MHz
{
AUXR &= 0x7F; //定时器时钟12T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x18; //设置定时初值
TH0 = 0xFC; //设置定时初值
TF0 = ; //清除TF0标志
ET0=;
EA=;
TR0 = ; //定时器0开始计时
}
void Delay500us() //@12.000MHz
{
unsigned char i, j; i = ;
j = ;
do
{
while (--j);
} while (--i);
}
void Delay1ms() //@12.000MHz
{
unsigned char i, j; i = ;
j = ;
do
{
while (--j);
} while (--i);
}
void Delay359500us() //@12.000MHz
{
unsigned char i, j, k; _nop_();
_nop_();
i = ;
j = ;
k = ;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
} int main(void)
{ Timer0Init(); ti=;
while ()
{
Delay500us();
SI=;
Delay1ms();
SI=;
Delay359500us();
};
} void wave() interrupt
{
CLK=!CLK; }
stc15w wave的更多相关文章
- RIFF和WAVE音频文件格式
RIFF file format RIFF全称为资源互换文件格式(Resources Interchange File Format),是Windows下大部分多媒体文件遵循的一种文件结构.RIFF文 ...
- IEEE 802.11p (WAVE,Wireless Access in the Vehicular Environment)
IEEE 802.11p(又称WAVE,Wireless Access in the Vehicular Environment)是一个由IEEE 802.11标准扩充的通讯协定.这个通讯协定主要用在 ...
- Wave - 花たん 音乐
Wave 歌手:花たん 所属专辑:Flower 間違えて宇宙終わって(宇宙因为一个错误而终结了) 青信号はいつも通り(通行的灯号一如往常的) 飛んでまた止まって(又再停止传播) また 飛びそうだ(然后 ...
- Web 播放声音(AMR 、WAVE)
最近甚是苦闷,属于边学边做,跳进了很多坑,别提有多惨了,不过结果还是不错滴,纵观前后,一句话足以概括 “痛并快乐着” ~~~ ok,我少说废话,下面来总结下 Web 播放声音一些注意事项. 说到 We ...
- 多媒体(2):WAVE文件格式分析
目录 多媒体(1):MCI接口编程 多媒体(2):WAVE文件格式分析 多媒体(3):基于WindowsAPI的视频捕捉卡操作 多媒体(4):JPEG图像压缩编码 多媒体(2):WAVE文件格式分析
- UVa 488 - Triangle Wave
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- modelsim 中 WAVE窗口中能不能只显示变量名,而不显示路径
可以的,在wave窗口左下角有一个黑色的logo,你点击它就可以省电路径,只显示port名称,再点击就切换回来了,如图红色圈圈标记的logo,你可以试试!
- C# 获取wave文件信息【转】
public class WaveHelper { /// <summary> /// 数据流 /// </summary> private Stream m_WaveData ...
- 【转载】PMC/PEC Boundary Conditions and Plane Wave Simulation
原文链接 PMC/PEC Boundary Conditions and Plane Wave Simulation (FDTD) OptiFDTD now has options to use Pe ...
随机推荐
- [转帖][分享] 关于系统DIY--by 原罪
http://wuyou.net/forum.php?mod=viewthread&tid=399277&extra=page%3D1 前几天我发了一个帖子<Windows组件w ...
- C风格字符串和C++string对象的相互转化
一.C风格的字符串转化为C++的string对象 C++中,string 类能够自动将C 风格的字符串转换成string 对象 #include <iostream> #include ...
- 报错:org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
报错环境: CDH中集成的hive服务,启动报错,所以初始化一下元数据. 配置文件:/etc/hive/conf hive-site.xml 命令目录:/opt/cloudera/parcels/CD ...
- 0003 - 基于xml的Spring Bean 的创建过程
一.目录 前言 创建 Bean 容器 加载 Bean 定义 创建 Bean Spring Bean 创建过程中的设计模式 总结 二.前言 2.1 Spring 使用配置 ApplicationCont ...
- 1816647 - Error "Data file of SAP Note is incomplete" uploading a note in SNOTE
ymptom When uploading an SAP Note in transaction SNOTE you receive the error "Data file of SAP ...
- 函数内联 inline,__inline,__forceinline
▶ 感谢大佬的总结[http://www.cnblogs.com/xuemaxiongfeng/articles/2464850.html] ● 存储限定符 __inline 与关键字 inline ...
- k8s定义Deployment,和service
定义一个Deployment和service做个简单的笔记 有时候我们需要开放Pod的多个端口,比如nginx的80和443端口,那如何定义Deployment文件呢,定义单个端口如下 apiVers ...
- Android Studio Intent使用(显式、隐式)
https://blog.csdn.net/u012005313/article/details/47006689 使用Intent能够使程序在不同活动中跳转,意及能够使用不同界面.Intent用法分 ...
- css选择器querySelector
* querySelector(css选择器)* 通过css选择器去获取一个元素* 它获取到的只有一个元素,如果说是有重复的,那它只取第一个** 主语* document 从整个文档里去获取元素* 父 ...
- # 20175213 2018-2019-2 《Java程序设计》第2周学习总结
## 教材学习内容总结 在第二周的学习过程中,我学习了第二章和第三章的内容.第二章中,我学习了基本数据类型和类型转换运算以及与C语言有着相同和不同的数组.标识符由字母,下划线,美元符号和数字组成,并且 ...