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;
}
}
 

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!
 

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.
 

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.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…