您的位置 首页 嵌入式

GPIO输出—操控蜂鸣器蜂鸣

/*****************************Copyright(c)********************************————–FileInfo—-

/*****************************Copyright (c)******************************

**————–File Info————————————————–

** File name:main.c
** Last modified Date: 2011-04-09
** Last Version:1.0
** Descriptions:The main() function example template
**————————————————————————-
** Created by:lxliu
** Created date:2011-04-09
** Version:1.0
**************************************************************************/
#include “config.h”

#define BEEP 1<<7 //P0.7操控蜂鸣器,低电平蜂鸣

/*************************************************************************
** 函数称号:DelayNS()
** 函数功用:长软件延时
** 进口参数:dly延时操控值,值越大,延时越长
** 出口参数:无
*************************************************************************/

void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly–)
for(i=0;i<50000;i++);
}

/*************************************************************************
** 函数称号:main()
** 函数功用:用P0.7操控BEEP,让蜂鸣器蜂鸣
** 调试阐明:需将跳线JP11和BEEP短接
*************************************************************************/

int main (void)
{
PINSEL0=0x00000000; //设置P0口为GPIO功用
IO0DIR=BEEP; //设置P0.7为输出

while(1)
{
IO0SET=BEEP; //蜂鸣器中止蜂鸣
DelayNS(10); //延时
IO0CLR=BEEP; //蜂鸣器蜂鸣
DelayNS(100);//延时
}
return 0;
}
/*****************************************************************************
** End Of File
******************************************************************************/

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/276064.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部