armchannel_y 2015-12-27 06:15 采纳率: 0%
浏览 2061

为什么微控制器的I/O针必须初始化

1.Briefly explain why the digital Input/Output pins on the microcontroller have to be initialized before they are used. Which line of code is responsible for the initialization of the I/O port pin?

2.The initialization in the program is “friendly”. Briefly explain why.

#include “LPC17xx.h”
void delay(volatile int value)
{
for(int i=0; i {
}
}
int main()
{
LPC_GPIO1->FIODIR |= 1< while(1)
{
LPC_GPIO1->FIOSET |= 1< delay(48000);
LPC_GPIO1->FIOCLR |= 1<<5;
delay(96000);
}
}

  • 写回答

2条回答 默认 最新

  • wuheng_1 2015-12-27 08:42
    关注

    从代码上看,这是GPIO部分;
    GPIO的针脚可以定义为输入针脚和输出针脚,不设定,单片机不知道针脚是做什么用的;
    所有的外设都需要设置控制寄存器,设置完成后才能对外设进行操作。

    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案