Thank you Joe, you help me lots..I manage to program 2 PIC today. PIC16F877A and PIC18F452. I was a good starting point for me..Link given by Joe is very helpful..i just put my sample code to blink LED here as reference for anyone facing same problem like me after this...
Code:
8:49 PM
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 1/31/2010 *
'* Version : 1.0 *
'* Notes : This is sample code to program PIC16F877A, *
'* configuration setting must be done carefully
'* (modified the setting based on your requirement).
'* This programm has been tested on SK40B successfully.
'* Please note that in order to assemble with MPASM,
'* please change accordingly at View>Compile and Program
'* Option and edit the INC file at C:/PBP/16F877A.INC with
'* the following:
'* NOLIST
'* ifdef PM_USED
'* LIST
'* include 'M16F87xA.INC' ; PM header
'* ;device pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
'* XALL
'* NOLIST
'* else
'* LIST
'* LIST p = 16F877A, r = dec, w = -302
'* INCLUDE "P16F877A.INC" ; MPASM Header
'* ;__config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
'* NOLIST
'* endif
'* LIST
'*
'* Note: sign ";" has been put infront of the 5 line and 12th. This will
'* avoid error by this way the configuration will be based on the user defined
'* as mention in the program below. INCLUDE "PI16F877A.INC" will be located in
'* MPASM folder under C: program File/Microchip/MPASM Suite/ PI16F877A
'*
'* SK40B can be used to program other PIC, but change need to be made on the
'* C:/PBP/16F877A.INC as mentioned above and of course the setting on config
'* below must be refer to PIC datasheet.
'****************************************************************
@ INCLUDE "P16F877A.INC" ; MPASM Header
@__config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _CPD_OFF & _BODEN_OFF
DEFINE OSC 20
trisc = $00
MAIN:
PORTC = $FF
PAUSE 500
PORTC= $00
PAUSE 500
GOTO MAIN
here is another code tested using PIC18F452..all port C is blinking make my eyes also blinking..
Code:
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : Rosmadi bin Abdullah *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 1/31/2010 *
'* Version : 1.0 *
'* Notes : This is sample code to program PIC18F452, *
'* configuration setting must be done carefully
'* (modified the setting based on your requirement).
'* This programm has been tested on SK40B successfully.
'* Please note that in order to assemble with MPASM,
'* please change accordingly at View>Compile and Program
'* Option and edit the INC file at C:/PBP/18F452.INC with
'* the following:
'*
' NOLIST
' ifdef PM_USED
' LIST
' "Error: PM does not support this device. Use MPASM."
' NOLIST
' else
' LIST
' LIST p = 18F452, r = dec, w = -311, f = inhx32
' INCLUDE "P18F452.INC" ; MPASM Header
' ;__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
' ;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
' ;__CONFIG _CONFIG4L, _LVP_OFF_4L
' NOLIST
' endif
' LIST
'EEPROM_START EQU 0F00000h
'BLOCK_SIZE EQU 8
'
'*
'* Note: sign ";" has been put infront of the line 10th to 12th. This will
'* avoid error. By this way the configuration will be based on the user defined
'* as mention in the program below. INCLUDE "P18F452.INC" will be located in
'* MPASM folder under C: program File/Microchip/MPASM Suite/ P18F452
'*
'* SK40B can be used to program other PIC, but change need to be made on the
'* C:/PBP/xxxx.INC as mentioned above and of course the setting on config
'* below must be refer to PIC datasheet.
'****************************************************************
' Also please locate the following statement in C:\Program Files\Microchip\MPASM Suite\P18F452
' and do the followin ammendment by placing ";" sign infront of the #define+++
';==========================================================================
'; 16Cxxx/17Cxxx Substitutions
';==========================================================================
'* ; #define DDRA TRISA ; PIC17Cxxx SFR substitution
'* ; #define DDRB TRISB ; PIC17Cxxx SFR substitution
'* ; #define DDRC TRISC ; PIC17Cxxx SFR substitution
'* ; #define DDRD TRISD ; PIC17Cxxx SFR substitution
'* ; #define DDRE TRISE ; PIC17Cxxx SFR substitution
@ INCLUDE "P18F452.INC" ; MPASM Header
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
' Oscillator switch OFF
' Use HS oscillator (20MHZ here)
@ __CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_ON_2L
' Brown out reset OFF
' Power-up timer ON
@ __CONFIG _CONFIG2H, _WDT_ON_2H
' Watch dog timer ON
'
@ __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
' Stack over/underflow OFF
' Low Voltage programming OFF
' Background debugger OFF
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
'code protect disable
DEFINE OSC 20
trisc = $00
MAIN:
PORTC = $FF
PAUSE 500
PORTC= $00
PAUSE 500
GOTO MAIN
Bookmarks