Portlarım yetmiyor...

MCU kullanırken bizleri en çok zorlayan şeylerden birisi portların yetmemesi.

Burada yazdığım minik proje ile 5 port ile 20 led yakmayı göstermeye çalışacağım. Biraz daha geliştirilip başka amaçlar ile kullanmak mümkün olabilir.

İyi eğlenceler...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

// PIC12F675 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG
#pragma config FOSC = INTRCIO   // Oscillator Selection bits (INTOSC oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-Up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF      // GP3/MCLR pin function select (GP3/MCLR pin function is digital I/O, MCLR internally tied to VDD)
#pragma config BOREN = ON       // Brown-out Detect Enable bit (BOD enabled)
#pragma config CP = ON          // Code Protection bit (Program Memory code protection is enabled)
#pragma config CPD = ON         // Data Code Protection bit (Data memory code protection is enabled)

#define _XTAL_FREQ 4000000

const uint8_t p[] = {0x01, 0x02, 0x01, 0x04, 0x01, 0x10, 0x01, 0x20, 0x02, 0x04, 0x02, 0x10, 0x02, 0x20, 0x04, 0x10, 0x04, 0x20, 0x10, 0x20};
const uint8_t t[] = {0x3C, 0x3C, 0x3A, 0x3A, 0x2E, 0x2E, 0x1E, 0x1E, 0x39, 0x39, 0x2D, 0x2D, 0x1D, 0x1D, 0x2B, 0x2B, 0x1B, 0x1B, 0x0F, 0x0F};

//------------------------------------------------------------------------------
void mcuInit(void)
{
    ANSEL = 0x00;
    CMCON = 0x07;
    OPTION_REG = 0b00000000;
    VRCON = 0b00000000;
    WPU = 0b00100000;
}
//------------------------------------------------------------------------------
void main(void)
{
    uint8_t sayi = 0;

    mcuInit();

    while(1)
    {
        for(sayi = 0; sayi < 20; sayi++)
        {           
            TRISIO = t[sayi];
            GPIO   = p[sayi];
            __delay_ms(500);
            GPIO   = 0;
        }
    }
}
//******************************************************************************

12F675 ile 20 Led