Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

change to PIC16F877A.. help.......

Status
Not open for further replies.

awanis

Junior Member level 1
Joined
Sep 15, 2009
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
malaysia
Activity points
1,387
how can i change this program to PIC16F877a
im beginner in micro controller..
this program is use to control the speed motor..

#include <p18f4580.h>
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
unsigned char x;

void read()
{
ADCON0bits.GO = 1;
while (ADCON0bits.GO == 1)
x = ADRESH;
}

void main (void)
{
ADCON1 = 0x00;
ADCON2 = 0x05;
TRISD = 0x00;
read();
CCP1CON=0;
PR2=250;
TRISCbits.TRISC2=0;
T2CON=0x01;
CCP1CON=0x3C;
TMR2=0;
T2CONbits.TMR2ON=1;
while(1)
{
ADCON0 = 0b00000101;
read();
CCPR1L = ~x;
PIR1bits.TMR2IF=1;
while(PIR1bits.TMR2IF==0);
PORTD = 0x01;
}
}
 

Slorn

Junior Member level 2
Joined
Oct 20, 2009
Messages
22
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,283
Location
Belgium
Activity points
1,412
First you will need a C compiler for the PIC16F877a. Microchip only has a free C compiler for 18F pics.

An other options is to translate the code to assembly yourself. It does not look too difficult.

Slorn
--
Dwengo... gets you started with microcontrollers!
 

ChrisC

Member level 2
Joined
Sep 30, 2009
Messages
51
Helped
14
Reputation
28
Reaction score
2
Trophy points
1,288
Location
London, UK
Activity points
1,760
Hitech do a PIC16 compiler which you can use in "lite" mode (i.e. absolutely no optimisation at all) indefinitely - for small bits of code like this it works just fine, and it integrates nicely with MPLAB if you want the full IDE/simulator experience.
 

SkeeterB08

Newbie level 6
Joined
Sep 1, 2008
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
NorthEast Mississippi, USA
Activity points
1,397
If you want to use C, You can download BoostC. I use MatrixMultimedia's Flowcode, and it creates a C file that compiles using BoostC. and the code I see in your first post looks like code you see from FlowCode.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top