Set Output Port High Low C

谁说胖子不能爱 提交于 2020-01-01 19:47:28

问题


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?


回答1:


#define portOut1 pin_c0
output_bit(portOut1, value)


来源:https://stackoverflow.com/questions/17751843/set-output-port-high-low-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!