文件名称:spm
- 所属分类:
- 源码下载
- 资源属性:
- [WORD]
- 上传时间:
- 2011-10-26
- 文件大小:
- 33kb
- 下载次数:
- 0次
- 提 供 者:
- daiweiran@yahoo.cn
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
#include"c8051f020.h"
#define Tcount 13333
sbit SPWM_OUT1=P0^4;
sbit SPWM_OUT2=P0^5;
//调制度为0.8//
unsigned int code sin_H[25]={26,78,129,178,224,267,305,338,367,389,405,415,418,415,405,389,367,338,305,267,224,178,129,78,26};
unsigned int code sin_L[25]={497,445,394,345,299,256,218,185,156,134,118,108,105,108,118,134,156,185,218,256,299,345,394,445,497};
unsigned max=24;
unsigned char i_SPWM1,i_SPWM2;
unsigned int temp0,temp1;
void SysclkInit(void)
{
OSCICN=0x87; //设置SYSCLK为16MHz内部振荡器
}
void PortInit(void)
{
XBR0=0x1d; //使CEX0和CEX1输出到P0.0、P0.1
XBR1=0x14; //外部中断0端脚来测频率,外部中断1端脚来测相位差
XBR2=0x40; //允许交叉开关和弱上拉
P0MDOUT=0xff; //端口引脚输出方式为推挽
}
void PCA0Init(void)
{
PCA0MD=0x00; //设置空闲等待方式,PCA时基=SYSCLK/12
//禁止CF中断
PCA0CPM0=0x4d; //PCA输出方式选择,8位pwm
PCA0CPM1=0x4d;
}
#define Tcount 13333
sbit SPWM_OUT1=P0^4;
sbit SPWM_OUT2=P0^5;
//调制度为0.8//
unsigned int code sin_H[25]={26,78,129,178,224,267,305,338,367,389,405,415,418,415,405,389,367,338,305,267,224,178,129,78,26};
unsigned int code sin_L[25]={497,445,394,345,299,256,218,185,156,134,118,108,105,108,118,134,156,185,218,256,299,345,394,445,497};
unsigned max=24;
unsigned char i_SPWM1,i_SPWM2;
unsigned int temp0,temp1;
void SysclkInit(void)
{
OSCICN=0x87; //设置SYSCLK为16MHz内部振荡器
}
void PortInit(void)
{
XBR0=0x1d; //使CEX0和CEX1输出到P0.0、P0.1
XBR1=0x14; //外部中断0端脚来测频率,外部中断1端脚来测相位差
XBR2=0x40; //允许交叉开关和弱上拉
P0MDOUT=0xff; //端口引脚输出方式为推挽
}
void PCA0Init(void)
{
PCA0MD=0x00; //设置空闲等待方式,PCA时基=SYSCLK/12
//禁止CF中断
PCA0CPM0=0x4d; //PCA输出方式选择,8位pwm
PCA0CPM1=0x4d;
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
压缩包 : SPWM_C程序.doc 列表