Furkan KELEŞOĞLU
Aktif Üye
- Katılım
- 12 Ekim 2019
- Mesajlar
- 497
Evet bugün Boot Loaderin ilk denemelerini attım. ( sadece gömülü sistem kısmı için)
Sonuç ? Hüsran
Araştırabildiğim kadar araştırdım. bunun sonucunda ortaya böyle bir yazılım cıkarttım. bu kodda ki amaç ise belirlediğim adresten itibaren FURKAN KELESOGLU yazması idi. Kodu pice yükledim daha sonra bread board'da pici calıştırdım biraz bekledim. sonra enerjiyi kestim pici progralayıcı takıyıp okudum normalde yazma adresi gösterdiğim yerden itibaren FURKANKELESOGLU karakterleri yazması gerekirken hiç bir şey yazmamış.
Neyse İlk başlangıcımızı yaptık zaten saat 4:45 sabah olacak benim beyinde offline konuma geçmeye başladı yarın devam edeceğim artık. öneri ve görüşlerinize açığım bu arada. o yüzden buraya koyuyorum ki hem bunu yaparken geçirdiğimiz aşamaları herkes görsün. ve varsa yanlış veya eksik bir şey sizlerin öneri ve görüşleriyle düzeltilmesi için.
Sonuç ? Hüsran
Kod:
// CONFIG1H
#pragma config FOSC = XT // Oscillator Selection bits (XT oscillator)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = SBORDIS // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 18 // Brown Out Reset Voltage bits (VBOR set to 1.8 V nominal)
// CONFIG2H
#pragma config WDTEN = OFF // Watchdog Timer Enable bit (WDT is controlled by SWDTEN bit of the WDTCON register)
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
// CONFIG3H
#pragma config CCP2MX = PORTC // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config HFOFST = ON // HFINTOSC Fast Start-up (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.)
#pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
// CONFIG4L
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
// CONFIG5L
#pragma config CP0 = OFF // Code Protection Block 0 (Block 0 (000800-003FFFh) not code-protected)
#pragma config CP1 = OFF // Code Protection Block 1 (Block 1 (004000-007FFFh) not code-protected)
#pragma config CP2 = OFF // Code Protection Block 2 (Block 2 (008000-00BFFFh) not code-protected)
#pragma config CP3 = OFF // Code Protection Block 3 (Block 3 (00C000-00FFFFh) not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected)
#pragma config WRT1 = OFF // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected)
#pragma config WRT2 = OFF // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected)
#pragma config WRT3 = OFF // Write Protection Block 3 (Block 3 (00C000h-00FFFFh) not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)
#define _XTAL_FREQ 4000000
#include <xc.h>
#include <stdint.h>
#define FLASH_HAFIZA_BASLANGIC 0x00001000
/////////// GLOBAL DEGISKEN TANIMLAMALARI /////////////
uint8_t string[20]="FURKANKELESOGLU";
///////////// GLOBAL FONKSIYON TANIMLAMALARI ////////////////
void FLASH_HAFIZA_ADRES_KUR(uint32_t adres);
void KESMELERI_KAPAT(void);
void KESMELERI_AC(void);
void FLASH_HAFIZAYI_SIL(void);
void FLASH_HAFIZAYA_YAZ(void);
void FLASH_HAFIZAYA_VERI_YUKLE(uint8_t* data , uint8_t uzunluk);
void FLASH_HAFIZAYA_VERI_YUKLE(uint8_t* data , uint8_t uzunluk)
{
// BU FONKSIYON HOLDING REGISTERINE DATALARI YAZAR.
uint8_t counter = 0x00;
for(counter = 0x00 ; counter < uzunluk ; counter++)
{
TABLAT = data[counter]; // DATA ARRAYINDAN COUNTER DEGERI KADAR ILERLE VE ILERLERDIGIN VERIYI TABLAT'A YAZ (HOLDING REGISTERINE BAK).
asm("TBLWT*+"); // TABLOYA YAZ SONRA TABLO POINTERI 1 ARTTIR.
}
}
void FLASH_HAFIZA_ADRES_KUR(uint32_t adres)
{
// BU FONKSIYON VERILEN ADRESI TABLET POINTERE BAYTLARA AYIRARAK YUKLER. VE SET EDER.
TBLPTRU = (adres & 0xFF0000) >> 16; // ADRESIN UPPER KISMINI YUKLE
TBLPTRH = (adres & 0xFF00) >> 8; // ADRESIN HIGH KISMINI YUKLE
TBLPTRL = (adres & 0xFF); // ADRESİN LOW KISMINI YUKLE
}
void FLASH_HAFIZAYI_SIL(void)
{
EECON1bits.EEPGD = 1;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 1;
EECON1bits.FREE = 1;
KESMELERI_KAPAT(); // KESMELERIN HEPSİNİ KAPAT CPU'YU RAHATSIZ ETMESIN.
EECON2 = 0x55; // EECON2 YE 0x55 YUKLE YETKI VER
EECON2 = 0xAA; // EECON2 YE 0xAA YUKLE YETKI VER
EECON1bits.WR = 1; // CPU SIMDI STALL MODA GECICEK YAKLASIK 2 MS DAHILI BIR KESME KURUCAK CPU , BENLE ALAKASI YOK
KESMELERI_AC(); // CPU STALL MODDAN CIKINCA KESMELERI AC
}
void FLASH_HAFIZAYA_YAZ(void)
{
EECON1bits.EEPGD = 1; // FLASH PROGRAM HAFIZANA ERISIMI AC.
EECON1bits.CFGS = 0; // FLASH PROGRAM HAFIZASINI SEC. ( 1 OLUR İSE CONFIGRATION REGISTERINE ERISIM ACILIR ).
EECON1bits.WREN = 1; // PROGRAM FLASHINA YAZMAYI ETKINLESTIR.
KESMELERI_KAPAT(); // TUM KESMELERI KAPAT.
EECON2 = 0x55; // FLASH HAFIZA ISLEMLERI ICIN ISTEKTE BULUN VE ETKINLESTIR.
EECON2 = 0xAA; // FLASH HAFIZA ISLEMLERI ICIN ISTEKTE BULUN VE ETKINLESTIR.
EECON1bits.WREN = 1; // YAZMAYI ICIN CPU YA CYCLE VER YANI YAZMAYI YAPMASI ICIN YOL VER ISLEMCIYE.
// CPU SUAN STALL MODUNA GECTI DAHILI TIMER KURDU YAKLASIK 2MS SURECEK
KESMELERI_AC(); // CPU STALL MODDAN CIKINCA KESMELERI AC. ( STALL MOD : ISLEMCININ HIC BIRSEYE YANIT VERMEDIGI ZAMANDIR).
}
void KESMELERI_KAPAT(void)
{
INTCONbits.GIE = 0; // KESMELERI KAPAT.
INTCONbits.GIEH = 0; // YUKSEK SEVIYELI KESMEYI KAPAT.
INTCONbits.GIEL = 0; // DUSUK SEVIYELI KESMEYI KAPAT.
INTCONbits.PEIE = 0; // CEVRESEL KESMELERI KAPAT.
}
void KESMELERI_AC(void)
{
INTCONbits.GIE = 1; // KESMELERI AC.
INTCONbits.GIEH = 1; // YUKSEK SEVIYELI KESMEYI AC.
INTCONbits.GIEL = 1; // DUSUK SEVIYELI KESMEYI AC.
INTCONbits.PEIE = 1; // CEVRESEL KESMELERI AC.
}
void main(void) {
FLASH_HAFIZA_ADRES_KUR(FLASH_HAFIZA_BASLANGIC);
NOP();
NOP();
FLASH_HAFIZAYA_VERI_YUKLE(string,20);
NOP();
NOP();
FLASH_HAFIZAYA_YAZ();
NOP();
NOP();
while(1)
{
// SONSUZ DONGU BLOGU.
}
}
Araştırabildiğim kadar araştırdım. bunun sonucunda ortaya böyle bir yazılım cıkarttım. bu kodda ki amaç ise belirlediğim adresten itibaren FURKAN KELESOGLU yazması idi. Kodu pice yükledim daha sonra bread board'da pici calıştırdım biraz bekledim. sonra enerjiyi kestim pici progralayıcı takıyıp okudum normalde yazma adresi gösterdiğim yerden itibaren FURKANKELESOGLU karakterleri yazması gerekirken hiç bir şey yazmamış.
Neyse İlk başlangıcımızı yaptık zaten saat 4:45 sabah olacak benim beyinde offline konuma geçmeye başladı yarın devam edeceğim artık. öneri ve görüşlerinize açığım bu arada. o yüzden buraya koyuyorum ki hem bunu yaparken geçirdiğimiz aşamaları herkes görsün. ve varsa yanlış veya eksik bir şey sizlerin öneri ve görüşleriyle düzeltilmesi için.