文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机硬件及网络 > psoc位操作
侵权投诉

psoc位操作

介绍了psoc进行为操作的的方法和注意事项

User Interface - Data Port Bit Manipulation

with the PSoC MCU

AN2033

Author: Darrin VallisAssociated Project: Yes

Associated Part Family: CY8C25xxx, CY8C26xxx

GET FREE SAMPLES HERE

Software Version: NA

Associated Application Notes: None

Application Note Abstract

This Application Note reveals programming tips to manipulate I/O port bits of the PSoC® microcontroller.

Introduction

Cypress MicroSystems Programmable System on Chip (PSoC ) microcontroller provides highly flexible I/O with every pin having configurable drive modes, interrupts and global routing connections.

Simple Macro to Flip Bits

A desirable feature would be to flip an I/O port bit with a simple statement like P0.0 = 1. Using C macro programming this is easily accomplished. Consider the following C code:

#include "m8c.h"

#define Port0_0(b) (PRT0DR = (b==0) ? (PRT0DR&0xFE) : (PRT0DR|0x01))

void main() {

Port0_0(1); // Set Port 0, bit 0 to 1 }

The C Compiler pre-processor in PSoC Designer replaces this Port0_0(1) call in main() with the macro definition before compiling. The assembly code generated is:

OR REG[0],1

So, we get an efficient translation into assembly from a very readable C format. All that remains is generating a header file to implement the call for each bit of all device ports. (See ports.h in Appendix A.)

Assembly vs. C

Efficient software is vital for embedded system design, especially with respect to I/O routines. PSoC MCU I/O ports are highly configurable, and directly accessible by firmware bit operations in PSoC Designer. This provides maximum flexibility for programmers. However, it can require code that is difficult to read.

Consider this common example: A hardware engineer wants to clear bit 6 of I/O port 0 (P0[6]). With a PSoC microcontroller, they would write the following assembly code:

export _main

_main:

and REG[PRT0DR], 0xBF ret

One line is easy to read, but a complex project can become increasingly difficult to read by others over time. The C version of the code would look like:

#include "m8c.h" void main() {

PRT0DR&=0xBF; }

psoc位操作

第1页

你可能喜欢

热门文档

相关文档

  • PSOC原理及操作基础教程

    PSOC 原理及操作教程 - Theory and Operation of PsoC PSOC 原理及操作教程 ...例如:某一种型号的单片机具有一个 16 位定时器和一个 8 位的定时器,那 么在...

  • PSoC_PSoC MCU实时操作系统

    应用手册 PSoC MCU实时操作系统 AN2046 作者:Edward Nova 相关项目:是 相关部件...定时器设置 采用名为RTOS_Timer8的8位定时器可以尽可能减少 对PSoC数字块资源...

  • 第八部分 PSoC Creator软件及设计流程

    ? ? 基于PSoC3工程的简单流程; 基于PSoC5工程的简单流程; 基于PLD的自定义...? PSoC3/5基本编程模型 -位变量的使用使用’bit’关键字声明位操作。下面给出...

  • PSoC Creator软件及设计流程

    它包含一个项目管理器和用于 源代码的集成C编辑器和汇编器,以及设计入口工具。 ? PSoC3/5基本编程模型 -位变量的使用使用’bit’关键字声明位操作。下面给出C...

  • PSOC原理及操作教程

    PSOC原理及操作教程_电子/电路_工程科技_专业资料。PSOC 原理及操作教程 第一...例如:某一种型号的单片机具有一个 16 位定时器和一个 8 位的定时器,那么在...

  • 给PSOC初学者10个实例

    RainPower 利用 PSOC 内部的 LED 模块设置 P2.1, 实现普通 IO 口的操作。 ...4、数字时钟(1) 1、实验任务利用四位共阴数码管、PSOC 内部 LED 数码管模块...

  • PSOC DESI AD

    PSoC 10页 5财富值 PSoC 2页 1财富值 psoc位操作 4页 免费 PSoC学习 14页 1财富值 PSoC 28页 2财富值 PSoC简介 4页 免费 pSOC设计与应用 16页 免费 ...

  • 第5章 PSoC编程和调试接口

    主机也发送奇偶校验位。 c)对于一个等待响应,表示PSoC5正在处理以前的交易。主 机能尝试最大四个连续的等待响应,查看时候接收到OK响 应,如果失败则放弃编程操作,...

  • PSoC

    PSoC(可编程片上系统) PSoC(可编程片上系统)是 Cypress 半导体生产的包含有 ... 6页 免费 psoc位操作 4页 免费 PSoC简介 4页 免费喜欢此文档的还喜欢...

  • PSoC_I2C硬件模块数据手册

    -5- 下列图表说明了数据写入、数据指针写入以及数据读取操作的总线通讯。请牢记,...无论字节是地址或数据 接收设备随后将适当的控制位写入至 12C_SCR寄存器 将...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email