ATmega8 için yazılmış olan kodları PİC için çevirebilirmyiz?

Başlatan mrtfb123, 25 Kasım 2017, 13:38:58

mrtfb123

Merhaba elimde ATmega8 için yazılmış kodlar var ATmega8 gömdüğüm zaman sorunsuz çalışıyor fakat pic16f877a ya gömmek istiyorum kodda ne gibi değişiklikler yapmam gerek.
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>

#define R1 PB0
#define Y1 PB1
#define G1 PB2

#define R2 PB3
#define Y2 PB4
#define G2 PB5

#define R3 PD5
#define Y3 PD4
#define G3 PD3

#define R4 PD2
#define Y4 PD1
#define G4 PD0

int main(void)
{
DDRB = 0xff;
DDRD = 0xff;
DDRC = 0x00;

PORTB = 0x00;
PORTD = 0x00;

while(1)
{
if((PINC&0x01) == 0x01)
{
PORTB |= (1<<G1);
PORTB |= (1<<Y2);
PORTD |= (1<<R3);
PORTD |= (1<<R4);

}
else if((PINC&0x02) == 0x02)
{
PORTB |= (1<<R1);
PORTB |= (1<<G2);
PORTD |= (1<<Y3);
PORTD |= (1<<R4); 

}

else if((PINC&0x04) == 0x04)
{
PORTB |= (1<<R1);
PORTB |= (1<<R2);
PORTD |= (1<<G3);
PORTD |= (1<<Y4);

}

else if((PINC&0x08) == 0x08)
{
PORTB |= (1<<Y1);
PORTB |= (1<<R2);
PORTD |= (1<<R3);
PORTD |= (1<<G4);

}

else
{
PORTB = 0x00;
PORTD = 0x00;

PORTB |= (1<<G1);
PORTB |= (1<<Y2);
PORTD |= (1<<R3);
PORTD |= (1<<R4);
_delay_ms(7000);

PORTB = 0x00;
PORTD = 0x00;

PORTB |= (1<<R1);
PORTB |= (1<<G2);
PORTD |= (1<<Y3);
PORTD |= (1<<R4);
_delay_ms(7000);

PORTB = 0x00;
PORTD = 0x00;

PORTB |= (1<<R1);
PORTB |= (1<<R2);
PORTD |= (1<<G3);
PORTD |= (1<<Y4);
_delay_ms(7000);

PORTB = 0x00;
PORTD = 0x00;
PORTB |= (1<<Y1);
PORTB |= (1<<R2);
PORTD |= (1<<R3);
PORTD |= (1<<G4);
_delay_ms(7000);
PORTB = 0x00;
PORTD = 0x00;
} 
}
}

mehmet

#define R1 PORTBbits.RB0
#define Y1 PORTBbits.RB1
#define G1 PORTBbits.RB2

#define R2 PORTBbits.RB3
#define Y2 PORTBbits.RB4
#define G2 PORTBbits.RB5

#define R3 PORTDbits.RD5
#define Y3 PORTDbits.RD4
#define G3 PORTDbits.RD3

#define R4 PORTDbits.RD2
#define Y4 PORTDbits.RD1
#define G4 PORTDbits.RD0

#define B1  PORTCbits.RC0
#define B2  PORTCbits.RC1
#define B3  PORTCbits.RC2
#define B4  PORTCbits.RC3

void main(void)
{

    PORTA = 0x00;
    ADCON1bits.PCFG = 0b0110;
    TRISA = 0x00;

    PORTB = 0x00;
    TRISB = 0x00;

    PORTC = 0x00;
    TRISC = 0xFF;

    PORTD = 0x00;
    TRISD = 0x00;

    PORTE = 0x00;
    TRISE = 0x00;

    while (1)
    {
        if (B1 == 0x01)
        {
            PORTB |= (1 << G1);
            PORTB |= (1 << Y2);
            PORTD |= (1 << R3);
            PORTD |= (1 << R4);
        }
        else if (B2 == 0x02)
        {
            PORTB |= (1 << R1);
            PORTB |= (1 << G2);
            PORTD |= (1 << Y3);
            PORTD |= (1 << R4);
        }
        else if (B3 == 0x04)
        {
            PORTB |= (1 << R1);
            PORTB |= (1 << R2);
            PORTD |= (1 << G3);
            PORTD |= (1 << Y4);
        }
        else if (B4 == 0x08)
        {
            PORTB |= (1 << Y1);
            PORTB |= (1 << R2);
            PORTD |= (1 << R3);
            PORTD |= (1 << G4);
        }
        else
        {
            PORTB = 0x00;
            PORTD = 0x00;
            PORTB |= (1 << G1);
            PORTB |= (1 << Y2);
            PORTD |= (1 << R3);
            PORTD |= (1 << R4);
            __delay_ms(7000);

            PORTB = 0x00;
            PORTD = 0x00;
            PORTB |= (1 << R1);
            PORTB |= (1 << G2);
            PORTD |= (1 << Y3);
            PORTD |= (1 << R4);
            __delay_ms(7000);

            PORTB = 0x00;
            PORTD = 0x00;
            PORTB |= (1 << R1);
            PORTB |= (1 << R2);
            PORTD |= (1 << G3);
            PORTD |= (1 << Y4);
            __delay_ms(7000);

            PORTB = 0x00;
            PORTD = 0x00;
            PORTB |= (1 << Y1);
            PORTB |= (1 << R2);
            PORTD |= (1 << R3);
            PORTD |= (1 << G4);
            __delay_ms(7000);
            PORTB = 0x00;
            PORTD = 0x00;
        }
    }
}

Gerisini siz çözersiniz...
Olan olmuştur,
olacak olan da olmuştur.
Olacak bir şey yoktur.
---------------------------------------------
http://www.mehmetbilgi.net.tr

mrtfb123

merhaba yeni gördüm kusura bakmayın hangi derleyicide yazdınız acaba bu kodları ?

mehmet

Olan olmuştur,
olacak olan da olmuştur.
Olacak bir şey yoktur.
---------------------------------------------
http://www.mehmetbilgi.net.tr