cygnal C8051F31X PIN设置

news/2025/2/14 3:58:57/

                 PIN的设置

     虽然做过几个项目,但对单片机PIN的设置一直不是很明白,前几天安装了silabs IDE的3.2,有很多例子。下面这个对此做了比较详细的说明。

P0.7与P3.3都是digital,所以P0MDOUT及P3MDOUT可以对相应的PIN做设置。

//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This function configures the crossbar and ports pins.
//
// To configure a pin as a digital input, the pin is configured as digital
// and open-drain and the port latch should be set to a '1'.  The weak-pullups
// are used to pull the pins high.  Pressing the switch pulls the pins low.
//
// To configure a pin as a digital output, the pin is configured as digital
// and push-pull. 
//
// An output pin can also be configured to be an open-drain output if system
// requires it.  For example, if the pin is an output on a multi-device bus,
// it will probably be configured as an open-drain output instead of a
// push-pull output.  For the purposes of this example, the pin is configured
// as push-pull output because the pin in only connected to an LED.
//
// P0.7   digital   open-drain    Switch 1
// P3.3   digital   push-pull     LED1
//-----------------------------------------------------------------------------
void PORT_Init (void)
{
   P0MDIN |= 0x80;                     // P0.7 is digital
   P3MDIN |= 0x08;                     // P3.3 is digital

   P0MDOUT = 0x00;                     // P0.7 is open-drain
   P3MDOUT = 0x08;                     // P3.3 is push-pull

   P0     |= 0x80;                     // Set P0.7 latch to '1'

   XBR1    = 0x40;                     // Enable crossbar and enable
                                       // weak pull-ups
}


http://www.ppmy.cn/news/160470.html

相关文章

Pinia的简单使用

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 一.什么是Pinia?二.Pinia 的使用2.1Pinia 的使用2.2 Pinia 的引入2.3 Pinia 模块的创建2.4 Pinia 数据页面的使用 三.pinia 中 修改 state 数据的方法。…

【医学+深度论文:F31】2017 IOS Press Automatic Identification of Glaucoma Using Deep Learning Methods

31 2017 IOS Press Automatic Identification of Glaucoma Using Deep Learning Methods Method : 分类 Dataset:HRF , RIM-ONE r1,RIM-ONE r2,RIM-ONE r3 Architecture: ROI GoogLeNet Results: AC HRF 90%, RIM-ONE r1 94.2% ,RIM-ONE…

小程序创建直播间接口返回 parameter shareImg must no be null rid: 6141c273-7ebc0b10-090f31f0

当调用小程序创建直播间接口时 接口返回 { "errmsg": "parameter shareImg must no be null rid: 6141c273-7ebc0b10-090f31f0", "errcode": 200002 } 但是这个shareImg 参数已经是传入的 最终 发现 raw text和json有区别得 当改为raw j…

RISC-V 整数寄存器(x0~x31)与浮点寄存器(f0~f31)数据交换

RV32F 32位整数和32位浮点数的转换: fmv.s.x rd, rs1 f[rd] x[rs1][31:0] fmv.x.s rd, rs1 x[rd] f[rs1][31:0] RV32D 32位整数和64位浮点数的交换,需要两个x寄存器来存储一个f寄存器的值,没有直接指令可以用。首先将f寄存器存储到堆栈…

仿百度搜索框支持拼音 输入联想

<!DOCTYPE html> <html> <head lang"en"> <meta charset"UTF-8"> <title>输入联想</title> <script src"http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <style> *{ ma…

kindeditor使用方法php,详细介绍如何使用kindEditor编辑器

kindEditor编辑器是一个由JS写成的在线编辑器&#xff0c;很多网站或CMS等都有用它&#xff0c;口碑不错&#xff0c;目前最新版本是4.1.10。 其实它的用法非常简单&#xff0c;我是在下载了它的安装包后看了一些demo然后就把它放到PHP啦的后台上去了。好了教程正式开始 一、下…

联想旭日F31XP驱动

声卡驱动&#xff1a; [url]http://211.100.43.194/DriverFilesUploadFloder/notebook//2007121113344698023/F31_XP_Audio.exe[/url] 蓝牙驱动&#xff1a; [url]http://211.100.43.194/DriverFilesUploadFloder/notebook//2007121113494977445/F31_XP_BlueTooth.exe[/url] 摄…

联想F31笔记本配置分析

引进了ThinkPad之后&#xff0c;联想笔记本的制作工艺确实有了大幅提升&#xff0c;而且外观设计也越来越简约实用&#xff0c;通俗地说就是很“大气”。 前一段时间一直关注了一段F41系列的笔记本&#xff0c;但当时预算不够&#xff0c;只好买了ThinkPadR60暂为代替。…