我的嵌入式第一个程序(实现计数器)
来源:互联网 发布:linux笔试题面试题 编辑:程序博客网 时间:2024/06/05 22:49
config.h
/****************************************Copyright (c)**************************************************
********************************************************************************************************/
#ifndef __CONFIG_H
#define __CONFIG_H
#include <LPC21xx.H>
#include <stdio.h>
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef unsigned char uint8; /* defined for unsigned 8-bits integer variable 无符号8位整型变量 */
typedef signed char int8; /* defined for signed 8-bits integer variable 有符号8位整型变量 */
typedef unsigned short uint16; /* defined for unsigned 16-bits integer variable 无符号16位整型变量 */
typedef signed short int16; /* defined for signed 16-bits integer variable 有符号16位整型变量 */
typedef unsigned int uint32; /* defined for unsigned 32-bits integer variable 无符号32位整型变量 */
typedef signed int int32; /* defined for signed 32-bits integer variable 有符号32位整型变量 */
typedef float fp32; /* single precision floating point variable (32bits) 单精度浮点数(32位长度) */
typedef double fp64; /* double precision floating point variable (64bits) 双精度浮点数(64位长度) */
#define Fosc 11059200 //Crystal frequence,10MHz~25MHz,should be the same as actual status.
//应当与实际一至晶振频率,10MHz~25MHz,应当与实际一至
#define Fcclk (Fosc * 4) //System frequence,should be (1~32)multiples of Fosc,and should be equal or less than 60MHz.
//系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ
#define Fcco (Fcclk * 4) //CCO frequence,should be 2、4、8、16 multiples of Fcclk, ranged from 156MHz to 320MHz.
//CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz
#define Fpclk (Fcclk / 4) * 1 //VPB clock frequence , must be 1、2、4 multiples of (Fcclk / 4).
//VPB时钟频率,只能为(Fcclk / 4)的1、2、4倍
#endif
c code:
#include "config.h"
void delay(uint32 dly)
{
uint32 loop;
for(;dly>0;dly--)
for(loop=0;loop<5000;loop++);
}
int main(void)
{
uint8 exp = 0x00000000;
uint32 InputStat;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
IO0DIR = 0x0000001F;
while(1)
{
IO0SET = 0x00000010 | exp;
InputStat = IO0PIN;
//ID0SET = 0x00060000 | 0x00000000;
if((InputStat&0x00060000)!=0x00060000)
{
if((InputStat&0x00060000)!=0x00040000)
{
IO0CLR = 0x00000010 | exp;
if(exp != 0x00000009)
exp ++;
else
exp = 0x00000000;
}
if((InputStat&0x00060000)!=0x00020000)
{
IO0CLR = 0x00000010 | exp;
if(exp != 0x00000000)
exp--;
else
exp = 0x00000009;
}
while((InputStat & 0x00060000)!=0x00060000)
{
InputStat = IO0PIN; // 等按键释放
}
}
}
return 0 ;
}
- 我的嵌入式第一个程序(实现计数器)
- 24进制计数器 - 我的第一个FPGA程序
- 我的第一个嵌入式程序诞生过程
- 我的嵌入式学习之路(一) linux 跑的第一个程序 LED灯
- 第一个嵌入式程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- mysql cluster表空间创建相关命令
- spring mvc 输出 json 异常处理
- 无法读取项目文件PMSWPF.csproj,请。。。。
- Eclipse failed to create the java virtual machine
- 不要过打折的生活,当你发现这些你有了,说明你开始成熟了
- 我的嵌入式第一个程序(实现计数器)
- 弃用gets(),改用fgets()就能解决问题了?!
- 千姿百态项目经理3——“牛逼”项目经理3
- 使用PHP 给网站 生成快照图片和缩略图
- 好书
- command_type
- 华为牛人的十年工作感悟
- 金币阵列问题
- 浅析对象池