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.

C++ programming tutorial for pic16f877A needed!!

Status
Not open for further replies.

chwoei

Newbie level 6
Joined
Dec 14, 2006
Messages
12
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,367
pic16f877a tutorial

hi,
i am currently doing a project using pic16f877A, i will be using 2 infrared sensors to detect obstacles. can any one give any tutorials or sample C++ code for PIC16F877A? and my infra output is analog. Its ok if the code is not for infared. any code written in c++ for pic16f877A is ok.



cheers,
Chang
 

+pic16f877a+tutorial programming led

how about try going to the vendor microchip... i believe that there exist such one... you will program pic in c language and the compiler will translate it to assembly... i have used such during undergrad class.
 

pic16f877a+c++

ohh ok... or any c code for pic16F877A tutorials?
 

c++ 0b11111111

An simple code in PIC 16F877A controled LED :D
//============================================================================================
#include<pic.h>
__CONFIG(HS & PWRTEN & BOREN & LVPDIS);
//define and interupt.......
void init(void);
void delay(void);
//---------------------------
void main()
{
CLRWDT();
init();
while(1)
{

PORTD = 0b11111111;
delay();
PORTD = 0x00;
delay();
}
CLRWDT();
}
//============================================================================================
//------define ports and interupt ---------------------
void init(void)
{
TRISD = 0b00000000; //=1 is IN, =0 is OUT
PORTD = 0b00000000;
TRISA = 0x255;
TRISB = 0x255;
TRISC = 0x255;
}
//---------Time delay ------------
void delay (void)
{
unsigned int i;
for(i=0;i<65535;i++)
{
NOP(); NOP(); NOP(); NOP(); NOP(); //anything work only delay
NOP(); NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP(); NOP();
NOP(); NOP(); NOP(); NOP(); NOP();
CLRWDT();
}
}
//=============================================THE END========================================
 

    chwoei

    Points: 2
    Helpful Answer Positive Rating
what does nop do on pic16f877a

hi ya,
this is good.. can i ask about the code. how u define this? can u explain?
PORTD = 0b11111111;
TRISD = 0b00000000; //=1 laf IN, =0 la OUT
PORTD = 0b00000000;
TRISA = 0x255;
TRISB = 0x255;
TRISC = 0x255;

and do u have any idea if i want to write a code using infrared sensor to control the motor?
 

Hello,
You should download MPLAB from the microchip.com web site and then the PICC Lite compiler from the hitech.com and the user guide and it comes with some explained examples

Regards.
 

chwoei said:
hi ya,
this is good.. can i ask about the code. how u define this? can u explain?
PORTD = 0b11111111;
TRISD = 0b00000000; //=1 laf IN, =0 la OUT
PORTD = 0b00000000;
TRISA = 0x255;
TRISB = 0x255;
TRISC = 0x255;

and do u have any idea if i want to write a code using infrared sensor to control the motor?
TRIS is used to define a port is input or ouput , use can define a bit in portD [D7.......D0] exam you can define TRISD=0b10101110 , this mean D7 is input, D0 is output .......... 0 means output , 1 means input
TRISA=0x255 is other way to define direction of port , it is the same TRISA=0b11111111
PORTD=0b0000000 mean we assign the value for PORTD
 

sorry,
could i ask that how do u get the pic.h header file from, cause i don`t have any ideas about the variables set in the header file. I will like a copy of the header file if possible to write some code. I need to know the commands like PORTA = the address in pic16F877A, so we could use directly in programming in c.

pls help
CHEERS,
CHANG
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top