简体   繁体   English

设置输出端口高低C

[英]Set Output Port High Low C

I'm using MPLAB to compile a program in C using the CCS compiler. 我正在使用MPLAB使用CCS编译器在C中编译程序。

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. 因此,我想将portOut1设置portOut1高电平或低电平。

I had used 3 ways to do it, but just one had worked. 我曾经用3种方法来做到这一点,但只有一种可行。 But I'm not satisfied with that. 但是我对此不满意。

1: (Doesn't work, why?) 1 :(不起作用,为什么?)

portOut1 = output5.value;

2: (Doesn't work, why?) 2 :(不起作用,为什么?)

output_bit(portOut1,value);

3: (Obviously work) 3 :(显然可以工作)

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM