设置输出端口高低C [英] Set Output Port High Low C

查看:121
本文介绍了设置输出端口高低C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MPLAB利用CCS编译器编译在C程序。

我想设置输出端口为高或低使用定义的端口。

  #bit portOut1 = PORTC.0

所以,我想我的设置 portOut1 高或低。

我用了3种方式来做到这一点,但只是一个工作过。但我不是满意。

1:(?不行的,为什么)

  portOut1 = output5.value;

2:(?不行的,为什么)

  output_bit(portOut1,值);

3:(显然工作)

  output_bit(pin_c0,值);

我不明白为什么第一和第二种方法是行不通的。

和我不想使用第三个,因为我不知道这脚做什么,除非我的评论,我不认为这是一个不错的方案做法。

任何人都知道一个办法做到这一点?或者有什么我做错了?


解决方案

 的#define portOut1 pin_c0
output_bit(portOut1,值)

I'm using MPLAB to compile a program in C using the CCS compiler.

I want to set an output port as high or low using defined ports.

#bit portOut1 = PORTC.0

So, I want to set my portOut1 high or low.

I had used 3 ways to do it, but just one had worked. But I'm not satisfied with that.

1: (Doesn't work, why?)

portOut1 = output5.value;

2: (Doesn't work, why?)

output_bit(portOut1,value);

3: (Obviously work)

output_bit(pin_c0, value);

I don't understand why the first and second way doesn't work.

And I don't want to use the third because I don't know what this pin do unless I comment, and I don't think that is a good program practice.

Anyone knows a way to do that? Or what I'm doing wrong?

解决方案

#define portOut1 pin_c0
output_bit(portOut1, value)

这篇关于设置输出端口高低C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆