Ini merupakan Template programming khas untuk PIC18F4550, Template ini bermula pada '//include'. Untuk memulakan aturcara, anda boleh terus fokus pada 'main' program.
Untuk detail setiap configuration word bit yang digunakan, boleh rujuk di C:\MCC18\doc\hlpPIC18ConfigSet
Template Programming:
DOWNLOAD TEMPLATE PROGRAMMING
//include the PIC18F model of PIC header file
#include <p18cxxx.h>
/**********************************************************
DEVICE CONFIGURATION WORDS *
**********************************************************/
//Configuration bits for PIC18F4550
#pragma config FOSC = HSPLL_HS
#pragma config PLLDIV = 5
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2
#pragma config FCMEN = ON
#pragma config IESO = ON
#pragma config PWRT = ON
#pragma config BOR = OFF
#pragma config WDT = OFF
#pragma config VREGEN = ON
#pragma config CCP2MX = ON
#pragma config PBADEN = ON
#pragma config LPT1OSC = OFF
#pragma config MCLRE = ON
#pragma config STVREN = ON
#pragma config LVP = OFF
#pragma config XINST = OFF
#pragma config DEBUG = OFF
#pragma config WRTB = ON
/************************************************
MAIN FUNCTION *
*************************************************/
void main (void)
{
}
Manakala template program dibawah ini pula adalah bagi mereka yang menggunakan compiler XC8.
Klik sini untuk download TEMPLATE PROGRAM UNTUK XC8
//Include Header File
#include <xc.h>
/**********************************************************
DEVICE CONFIGURATION WORDS *
**********************************************************/
//Configuration bits for PIC18F4550
#pragma config CONFIG1L = 0x24 //0b00100100
#pragma config CONFIG1H = 0xCE //0b11001110
#pragma config CONFIG2L = 0x38//0b00111000
#pragma config CONFIG2H = 0x00//0b00000000
#pragma config CONFIG3H = 0x81//0b10000001
#pragma config CONFIG4L = 0x81//0b10000001
#pragma config CONFIG5L = 0x0F//0b00001111
#pragma config CONFIG5H = 0xC0//0b11000000
#pragma config CONFIG6L = 0x0F//0b00001111
#pragma config CONFIG6H = 0xA0//0b10100000
#pragma config CONFIG7L = 0x0F//0b00001111
#pragma config CONFIG7H = 0x40//0b01000000
void main(void)
{
}
No comments:
Post a Comment