Summary of Information Velleman K8048 – 12F675 not working
I also ran into the PIC12F & K8048 problems as discussed on this forum. Although I found all the information on the forum, it still took me some time to solve the problem as the information is scattered around in the posts.
-
Should you run into problems programming your PIC12F microprocessors, don’t panic, there might be a way to fix your PIC12F again to work in many projects.
-
The starting point of information is that you should know that when you use the internal oscillator of the PIC12F processors, the PIC12F processors use a value located at 0X3FF for calibrating the accuracy of the internal oscillator. This is called the OSSCAL value. You should also know that when you erase the PIC12F and re-programme it this value might be lost. Without this value the PIC12F may or may not work at all – in most cases the PIC12F will not.
-
When you unpack your PIC12F processors the first thing to do is to read the memory contents of each one and make a note of the value at 0X3FF. This person has engineered and ingenious method of recording the value, follow this link:
petesworld.demon.co.uk/homeb … piccal.htm
If you have lost the value, Microchip explains in application note AD250 how to re-calibrate the PIC, however it does not look like a task you can undertake on the dining room table. If you have lost your OSSCAL value, and need high precision timing functions, you will have to purchase another PIC12F. For non critical, hobby and to revive your PIC12F, you might want to try 0xFF/2 = 0x80 as a value. This will get the PIC12F internal 4.0MHz PIC12F oscillator going at a frequency only known to the PIC12F.
- There are two pieces of software available from Velleman you need to use to programme the PIC12F processors on the K8048 board. The first program is Progpic2.exe and the second is PicProg2006.exe + a patch file (picprog2006_patch_v2026.zip) for this program.
Install these and ensure that the K8048 is working, read the instructions and documentation accompanying the programming software thoroughly.
Progpic2.exe – Does not save and restore the OSSCAL value. But can “Bulk erase” the memory contents.
PicProg2006.exe – Does save and restore the OSSCAL value with the patch installed.
-
To revive your broken PIC12F.
a.) Remove power to the K8048 board; insert the PIC12F and short D7 with a small crocodile clip lead or I have soldered a small toggle switch over D7 and used super glue to glue it onto SK2 (the top of the DB9 connector). Put SW5 into the Prog position, restore power.
b.) Now use Progpic2.exe to “Bulk erase” the memory of the PIC12F. This will work, however you might need to try a couple of times or sometimes you need to remove the power to the board and re-connect it.
c.) If you have the OSSCAL value, you can edit the value after the ORG 0x3FD in the attached .asm program listing and recompile and link into a .hex file and programme your PIC12F still using Propic2.exe, else use the generic value of 0x80.
d.) Should everything work OK, LD1&2 will start flashing.
e.) You can now remove power to the K8048 board and remove the short over D7. -
You should now switch to the PicProg2006 program to programme your PIC12F, this will ensure that the OSSCAL value is saved and restored during each re-programming PIC12F cycle.
The usual apply; do not use this code if you do not know what you are doing. You can not blame me for anything you break or damage using this code. I the bulk of the code was written by someone else and I don’t know who that person is. I did not retain the information in the header for some reason, so my apologies to the original author.
— Copy from here and compile in MPLAB Ver 7.51 or Microchip MASM.
list p=12f675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
#define ADCpresent
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
; errorlevel -302 ; suppress banksel warning messages
;===============================================
; Variable Definition
;===============================================
timer1 EQU H'20' ; Used in delay routine
timer2 EQU H'21' ; " " "
pattern EQU H'22' ; Pattern data for LED light show
; Bank Select macro instructions
#define setbank0 bcf STATUS,RP0 ; Sel Bank 0
#define setbank1 bsf STATUS,RP0 ; Sel Bank 1
;**************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
goto main
; *********************************************
; * delay routine *
; *********************************************
DELAY_ROUTINE movlw D'255' ;54 Generate approx 10mS delay at 4Mhz CLK
movwf timer2
del_loop1 movlw D'255' ;60
movwf timer1
del_loop2 decfsz timer1,F
goto del_loop2
decfsz timer2,F
goto del_loop1
retlw 0
main
; ************************************
; Initialisation and startup code block
; -------------------------------------------------
setbank1 ; switch to register bank 1
clrf GPIO ;Init GPIO
movlw 0xFF
movwf TRISIO
IFDEF OSCCAL ; defined only for 12F629 / 675
call 0x3FF ; read factory oscillator calibration value
movwf OSCCAL ; write to OSCCAL register
; If using a 12F629/675 this value must be present
; and correct, or the code will not function properly
; if it functions at all.
ENDIF
IFDEF ADCpresent
clrf ANSEL ; Set ports for digital mode (12F675 / 12F683 only)
ENDIF
bsf WPU,GP5 ; enable weak-pull-up for SW1 input
movlw 0x07 ; load W=7
movwf CMCON ; disable Comparator on 12F675/627
setbank1
movlw b'00101011'
movwf TRISIO ; Set TRIS register
setbank0
Loop
movlw b'00010100' ;Activate LD2 (GP4) & LD1 (GP2)
movwf GPIO
call DELAY_ROUTINE
movlw b'00000000' ;De-activate LD2 (GP4) & LD1 (GP2)
movwf GPIO
call DELAY_ROUTINE
goto Loop
; If you loose the OSSCAL value in the PIC12F
; this code can be used to put the value back
ORG 0x3FF
; retlw 0x44 ; This value for your PIC12F e.g. 0x44
retlw 0x80 ; Generic value 0xFF/2 = 0x80
END ; directive 'end of program'
I hope this helps.