- 1、本文档共3页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
GPIO输入、输出控制实验(蜂鸣3次、LED显示零)
蜂鸣3次:
#include config.h
#define BEEPCON 0void DelayNS (uint32 uiDly)
{
uint32 i;
for (; uiDly 0; uiDly--)
{
for(i = 0; i 50000; i++);
}
}
int main (void)
{
uint32 j =3;
PINSEL0=0
IO0DIR=BEEPCON;
while(j0)
{ M
IO0CLR=BEEPCON;
DelayNS(10);
IO0SET=BEEPCON;
DelayNS(10);
j--;
}
IO0CLR=BEEPCON;
return (0);
}
LED显示零:
#include config.h
#define ds_a (1 12)
#define ds_b (1 25)
#define ds_c (1 11)
#define ds_d (1 13)
#define ds_e (1 26)
#define ds_f (1 4)
#define ds_g (1 24)
#define dp (1 10)
#define com1 (1 6)
#define com2 (1 5)
void DelayNS (uint32 uiDly)
{
uint32 i;
for (; uiDly 0; uiDly--)
{
for(i = 0; i 50000; i++);
}
}
int main (void)
{
PINSEL0=0
PINSEL1=0
IO0DIR=ds_a|ds_b|ds_c|ds_d|ds_e|ds_f|ds_g|dp|com1|com2;
while(1)
{
IO0CLR=com1;
IO0CLR=com2;
IO0CLR=dp;
IO0CLR=ds_a;
IO0CLR=ds_b;
IO0CLR=ds_c;
IO0CLR=ds_d;
IO0CLR=ds_e;
IO0CLR=ds_f;
IO0SET=ds_g;
DelayNS(10);
IO0SET=com1;
IO0SET=com2;
IO0SET=dp;
IO0SET=ds_a;
IO0SET=ds_b;
IO0SET=ds_c;
IO0SET=ds_d;
IO0SET=ds_e;
IO0SET=ds_f;
IO0SET=ds_g;
DelayNS(10);
}
return (0);
}
LED显示零(最简):
#include config.h
#define ds_a (1 12)
#define ds_b (1 25)
#define ds_c (1 11)
#define ds_d (1 13)
#define ds_e (1 26)
#define ds_f (1 4)
#define ds_g (1 24)
#define dp (1 10)
#define com1 (1 6)
#define com2 (1 5)
void DelayNS (uint32 uiDly)
{
uint32 i;
for (; uiDly 0; uiDly--)
{
for(i = 0; i 50000; i++);
}
}
int main (void)
{
PINSEL0=0;
PINSEL1=0;
IO0DIR=ds_a|ds_b|ds_c|ds_d|ds_e|ds_f|ds_g|dp|com1|com2;
IO0CLR=ds_a|ds_b|ds_c|ds_d|ds_e|ds_f|ds_g|dp;
while(1)
{
IO0CLR=com1|com2;
DelayNS(50);
IO0SET=com1|com2;
DelayNS(50);
}
return (0);
}
文档评论(0)