Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write a C program for PIC16f877?

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hai.......

How to write a C program??

i using PIC 16f877, i use PortC as a input, can i write a program when PIC receive 8 input signal than this all input convert to binary form?? example x=0b01010101. How to write the program in C...


Thy...
 

pic16f877 c programming

Can you clarify your question? And what PIC C software are you using CCS C?

Of course your input is always in binary form as it is digital, but when it is in group of 8 or a byte, always it is better to address it as a hexadecimal.
 

set_tris_c

glenjoy said:
Can you clarify your question? And what PIC C software are you using CCS C?

Of course your input is always in binary form as it is digital, but when it is in group of 8 or a byte, always it is better to address it as a hexadecimal.


Ya... you are right CCS C. Sorry.... How to change in hexadecimal, example input is 00001111 than how to change in hex??? can you give sample??

Do you have MSN and Mail i can contect you easy....

Thy....
 

pic16f877a programs

What do you mean how to change to hexadecimal? You are handling microcontrollers without understanding Base-N conversions?

Search GOOGLE for binary to hexadecimal conversion.

I will only teach you how to read the ports in a PORT of PIC.

On CCS C there is a command INPUT_X() where X is the PORT letter, either A,B,C,D or E.

But of course your must set the TRI-State buffers first to input.

For example PORT_C:

set_tris_c(0x0F); // means higher nibble of port c is output and lower nibble is input

so if the instruction is:

set_tris_c(0xFF); // means all pins are inputs

to get the value of the port pins:

char in_value;

in_value = input_c();

// if the value you read in in_value is 0x00 means all port pin inputs are logic 0.

if you are reading CCS C help file you can see there that you can get the value of a single pin without any problem.
 

pic16f877a c programming

glenjoy said:
What do you mean how to change to hexadecimal? You are handling microcontrollers without understanding Base-N conversions?

Search GOOGLE for binary to hexadecimal conversion.

I will only teach you how to read the ports in a PORT of PIC.

On CCS C there is a command INPUT_X() where X is the PORT letter, either A,B,C,D or E.

But of course your must set the TRI-State buffers first to input.

For example PORT_C:

set_tris_c(0x0F); // means higher nibble of port c is output and lower nibble is input

so if the instruction is:

set_tris_c(0xFF); // means all pins are inputs

to get the value of the port pins:

char in_value;

in_value = input_c();

// if the value you read in in_value is 0x00 means all port pin inputs are logic 0.

if you are reading CCS C help file you can see there that you can get the value of a single pin without any problem.


Hai...

You mean set_tris_c(0x0F); the 0x0F the 0F is port c is o/p and 0xFF is i/p.
If 0x1F, 0x2F,.... stand for what??

The example that you give is

-------------------------------------------------------
set_tris_c(0xFF); // means all pins are inputs

char in_value; // Why you put char not int???
in_value = input_c();
-------------------------------------------------------

if my input is 10001100 can i convert to hex 0x8C as you say.....


Thy....
 

pic16f877 c

Better read C programming by Kernigham and Richie first.

It is one of the best ways to learn C.
 

pic16f877a c

glenjoy said:
Better read C programming by Kernigham and Richie first.

It is one of the best ways to learn C.

--------------------------
#define LCD 0x81
--------------------------

What the meaning for 0x81??

Added after 4 minutes:

glenjoy said:
Better read C programming by Kernigham and Richie first.

It is one of the best ways to learn C.


----------------------------------
#define LCD 0x81
----------------------------------

Above what's the meaning for??
 

pic16f877 in c

it means name the equate the number 0x81 to LCD.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top