PICkit 3 build problem

Thread Starter

Old Frank

Joined Jul 23, 2016
17
When my PICkit 3 is told to "build" it insists that a file must be included, in spite of displaying the hex code of my Assembler. I've some experience with a K150 using Oshonsoft simulation and the Microbrn programmer. I've tried local colleges for help and even posted a Facebook appeal, but to no avail. Any suggestions?
... and "sorry" if this is in the wrong place, but I'm getting desperate.
 

Thread Starter

Old Frank

Joined Jul 23, 2016
17
Ye gods, John. That was quick.
I need to use the PICkit 3 because the K150 doesn't support the newer PIcs I'm trying to use - with DAC. I'll need to simulate and make changes then, eventually, program a 12HV752 (to start with).
The file is very incomplete, but here (I hope) it is:
[
list p=12HV572 ; list directive to define processor
#include <p12HV572.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

;***** VARIABLE/CONSTANT DEFINITIONS***********************************
w_temp EQU 0x40 ; variable used for context saving
status_temp EQU 0x41 ; variable used for context saving

LEVCNTR EQU 43h ;Counter for voltage level pointer
HIINTERCNTR EQU 44h ;Counter for FFs in interval
CNTRFF EQU 45h ;Counter for interval - starts at FF
LOINTERCNTR EQU 46h ;Counter for units in interval
RESULTHI EQU 51h ;Store for AD result's upper 8 bits
RESULTLO EQU 52h ;Store for AD result's lower 8 bits
LEVEL EQU 53h ;Store for LEVTABLE value
HIINTERVAL EQU 54h ;Store for HIINTERTABLE value
LOINTERVAL EQU 56h ;Store for LOINTERTABLE value
;**********************************************************************
ORG 0x000 ; processor reset vector
goto MAIN ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save contents of STATUS register
;ISR here
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt

MAIN
banksel ANSELA
movlw b'00010010' ;Set <RA4&RA1> to an.
movwf ANSELA ; & others to dig.
banksel TRISA
movlw b'00011000' ;Set <RA4:3> to input
movwf TRISA ; & <RA2:0> to output
banksel PIE1
bsf PIE1,ADIE ;Enable ADC interrupt
bsf INTCON,GIE ;Enable all interrupts
banksel ADCON0
movlw b'00001101' ;Left justified
movwf ADCON0 ;Vdd is Vref & AN3 & ADC on
bsf ADCON1,4 ;
banksel DACCON0
movlw b'10100000' ;DAC enabled
movwf DACCON0 ;with O-P on pin 1.

LEVEL_SET ;
banksel LEVCNTR ;Voltage level pointer
movlw 05h ;Put 05d in because 1 is added at look-up start.
NEXT_LEVEL
banksel LEVCNTR ;Voltage level pointer
movwf LEVCNTR ;Puts latest value in voltage level pointer

COL_LEVEL ;Collects value for voltage level
movlw LOW LEVTABLE
addwf LEVCNTR,F
movlw HIGH LEVTABLE
btfsc STATUS,C
addlw 1
movwf PCLATH
movf LEVCNTR,W
call LEVTABLE ;Put value
movwf LEVEL ;into LEVEL store
movwf DACCON1 ;and output to RA1

ADCIN ;Reads pot'r for interval time
bcf PIR1,ADIF ;Clear AD interrupt flag
bsf ADCON0,1 ;Start conversion
nop ;Delay to allow
nop ;settling time.
btfsc ADCON0,1 ;Is conversion done?
goto $-1 ;If not, test again.
banksel ADRESH ;
movf ADRESH,W ;Read uppermost 8 bits
movwf RESULTHI ;into GPR space
movf RESULTHI,1 ;This is to check for
btfss STATUS,Z ;AD value of zero, otherwise
decf RESULTHI,1 ;dec. result to avoid FFh - crash.

COL_HIINTERVAL ;Collects value for interval time
movlw LOW HIINTERTABLE
addwf RESULTHI,F
movlw HIGH HIINTERTABLE
btfsc STATUS,C
addlw 1
movwf PCLATH
movf RESULTHI,W
call HIINTERTABLE ;Put nr of FFs
movwf HIINTERVAL ;into HIINTERVAL store.

COL_LOINTERVAL ;Collects value for interval time
movlw LOW LOINTERTABLE
addwf RESULTHI,F
movlw HIGH LOINTERTABLE
btfsc STATUS,C
addlw 1
movwf PCLATH
movf RESULTHI,W
call LOINTERTABLE ;Put nr of units
movwf LOINTERVAL ;into LOINTERVAL store.

;Go through off-time counts - MID, UNIT

MIDTIME ;Deals with number of FFs in off-time
LOOP0A
movf HIINTERVAL,0 ;Put nr of FFs
movwf HIINTERCNTR ;in HIINTERCNTR.
LOOP1A
movlw FFh ;Put FFh in
movwf CNTRFF ;CNTRFF
LOOP2A
decfsz CNTRFF,1 ;Dec. CNTRFF to zero
goto LOOP2A ;with inner loop
decfsz HIINTERCNTR,1 ;Dec. HIINTERCNTR until nr of
goto LOOP1A ;FFs is zero.

UNITIME ;Deals with lower byte in off-time
movf LOINTERVAL,0 ;Put LOINTERVAL (nr of UNITS)
movwf LOINTERCNTR ;in LOINTERCNTR.
LOOP1B
decfsz LOINTERCNTR,1 ;Decrement LOINTERCNTR
goto LOOP1B ;until it is zero.
decfsz LEVCNTR,1 ;Dec. LEVCNTR
goto NEXT_LEVEL ;Loop for next voltage level
goto LEVEL_SET ;Loop for next half-cycle

ORG 0x100
LEVTABLE
addwf PCL,1
retlw 0Fh ;
retlw 1Ah ;
retlw 1Eh
retlw 1Ah
retlw 0Fh
retlw 00h

ORG 0x200
HIINTERTABLE
addwf PCL,1
retlw D9h ;These values
retlw 6Ch ;have been
retlw 36h ;set for
retlw 24h ;half
retlw 1Bh ;cycle
retlw 15h ;times.

ORG 0x300
LOINTERTABLE
addwf PCL,1
retlw 03h ;These values
retlw 81h ;have been
retlw 40h ;set for
retlw 2Bh ;half
retlw 20h ;cycle
retlw B3h ;times.]
Is this the right way to present it?
Frank
 

MaxHeadRoom

Joined Jul 18, 2013
23,079
Your code must be including a .INC file that is missing.
p12HV572.inc for example, and this must be listed in the build files.
Max.
 

Thread Starter

Old Frank

Joined Jul 23, 2016
17
I've tried to use the Microchip forums, but keep having insurmountable problems trying to login. In spite of using correct user name & password, it persists in not activating my account. Hence my desperation.
 

MaxHeadRoom

Joined Jul 18, 2013
23,079
This is my build file samples, it is not enough to just list it in the main file, in MPLAB it must be inluded in the *.MCW as shown.

upload_2016-8-16_14-52-42.png
Max.
 

jpanhalt

Joined Jan 18, 2008
11,088
Are you sure the device is not a 12F(HV)752 instead of 12F(HV)572? I can't find 12F(HV)572 in my version of MPLab.

I tried compiling as a 12x752 and there are a lot of husekeeping items and a few symbols not defined errors.

Please confirm the chip. I may need to update. I suspect it is not a 12F5xx as they don't have interrupts.

Can you post the code using code tags, e.g., [code=ASM] ... [/code]

John
 

Thread Starter

Old Frank

Joined Jul 23, 2016
17
This is my build file samples, it is not enough to just list it in the main file, in MPLAB it must be inluded in the *.MCW as shown.

View attachment 110562
Max.
Thanks, Max. I'll look again in the morning with the PICkit 3 stuff on screen. My spring runs down about 9p.m. (now in N. Wales) and thinking is even harder at my age.
I used a PICkit 2 a few years ago and had little trouble, but I've forgotten how I got it to work.
The K150 etc. was a doddle - almost self-explanatory. The PICkit 3 is all bells & whistles, by comparison.
Thanks again.
Frank
 

Thread Starter

Old Frank

Joined Jul 23, 2016
17
Are you sure the device is not a 12F(HV)752 instead of 12F(HV)572? I can't find 12F(HV)572 in my version of MPLab.

I tried compiling as a 12x752 and there are a lot of husekeeping items and a few symbols not defined errors.

Please confirm the chip. I may need to update. I suspect it is not a 12F5xx as they don't have interrupts.

Can you post the code using code tags, e.g., [code=ASM] ... [/code]

John
You're right, John. It's a 12HV752, not 572, and I didn't notice that. But that shouldn't cause my problem, should it?
 

jpanhalt

Joined Jan 18, 2008
11,088
You're right, John. It's a 12HV752, not 572, and I didn't notice that. But that shouldn't cause my problem, should it?
On my machine it does. There are things like bank setting, interrupts, include files, and actually the names of the ports that could differ.

That was an easy fix, but the defines need work. Also, to compile, the programs needs an END command. Again easy.

Now that we both know the chip, :) I'll take another look at it. Don't feel bad about that. When "movfw" was commonly used as an instruction, I always mixed that up with "movwf."

John
 

jpanhalt

Joined Jan 18, 2008
11,088
This compiles. I did some fixes you need to address.
1) Define your radix as hex. The compiler doesn't seem to like xxh when the first digit is an alpha character, so I changed them to 0xnn. EDIT: The real problem probably was that I forgot to disable case sensitivity. Leave it as you had it, but be sure to do that in the compiler settings. I usually use radix dec
2) I just went with the default configuration. You do not want that. So, read the configuration section of toe datasheet and use the correct bit names.
John
Code:
     list p=12HV752 ; list directive to define processor
     #include <p12HV752.inc> ; processor specific variable definitions
     __CONFIG 0x3FFF ;_CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

;***** VARIABLE/CONSTANT DEFINITIONS***********************************
w_temp EQU 0x40 ; variable used for context saving
status_temp EQU 0x41 ; variable used for context saving

LEVCNTR EQU 43h ;Counter for voltage level pointer
HIINTERCNTR EQU 44h ;Counter for FFs in interval
CNTRFF EQU 45h ;Counter for interval - starts at FF
LOINTERCNTR EQU 46h ;Counter for units in interval
RESULTHI EQU 51h ;Store for AD result's upper 8 bits
RESULTLO EQU 52h ;Store for AD result's lower 8 bits
LEVEL EQU 53h ;Store for LEVTABLE value
HIINTERVAL EQU 54h ;Store for HIINTERTABLE value
LOINTERVAL EQU 56h ;Store for LOINTERTABLE value
;**********************************************************************
     ORG 0x000 ; processor reset vector
     goto MAIN ; go to beginning of program
     ORG 0x004 ; interrupt vector location
     movwf w_temp ; save current W register contents
     movf STATUS,w ; move status register into W register
     movwf status_temp ; save contents of STATUS register
     ;ISR here
     movf status_temp,w ; retrieve copy of STATUS register
     movwf STATUS ; restore pre-isr STATUS register contents
     swapf w_temp,f
     swapf w_temp,w ; restore pre-isr W register contents
     retfie ; return from interrupt

MAIN
     banksel ANSELA
     movlw b'00010010' ;Set <RA4&RA1> to an.
     movwf ANSELA ; & others to dig.
     banksel TRISA
     movlw b'00011000' ;Set <RA4:3> to input
     movwf TRISA ; & <RA2:0> to output
     banksel PIE1
     bsf PIE1,ADIE ;Enable ADC interrupt
     bsf INTCON,GIE ;Enable all interrupts
     banksel ADCON0
     movlw b'00001101' ;Left justified
     movwf ADCON0 ;Vdd is Vref & AN3 & ADC on
     bsf ADCON1,4 ;
     banksel DACCON0
     movlw b'10100000' ;DAC enabled
     movwf DACCON0 ;with O-P on pin 1.

LEVEL_SET ;
     banksel LEVCNTR ;Voltage level pointer
     movlw 05h ;Put 05d in because 1 is added at look-up start.
NEXT_LEVEL
     banksel LEVCNTR ;Voltage level pointer
     movwf LEVCNTR ;Puts latest value in voltage level pointer
 
COL_LEVEL ;Collects value for voltage level
     movlw LOW LEVTABLE
     addwf LEVCNTR,F
     movlw HIGH LEVTABLE
     btfsc STATUS,C
     addlw 1
     movwf PCLATH
     movf LEVCNTR,W
     call LEVTABLE ;Put value
     movwf LEVEL ;into LEVEL store
     movwf DACCON1 ;and output to RA1

ADCIN ;Reads pot'r for interval time
     bcf PIR1,ADIF ;Clear AD interrupt flag
     bsf ADCON0,1 ;Start conversion
     nop ;Delay to allow
     nop ;settling time.
     btfsc ADCON0,1 ;Is conversion done?
     goto $-1 ;If not, test again.
     banksel ADRESH ;
     movf ADRESH,W ;Read uppermost 8 bits
     movwf RESULTHI ;into GPR space
     movf RESULTHI,1 ;This is to check for
     btfss STATUS,Z ;AD value of zero, otherwise
     decf RESULTHI,1 ;dec. result to avoid FFh - crash.

COL_HIINTERVAL ;Collects value for interval time
     movlw LOW HIINTERTABLE
     addwf RESULTHI,F
     movlw HIGH HIINTERTABLE
     btfsc STATUS,C
     addlw 1
     movwf PCLATH
     movf RESULTHI,W
     call HIINTERTABLE ;Put nr of FFs
     movwf HIINTERVAL ;into HIINTERVAL store.

COL_LOINTERVAL ;Collects value for interval time
     movlw LOW LOINTERTABLE
     addwf RESULTHI,F
     movlw HIGH LOINTERTABLE
     btfsc STATUS,C
     addlw 1
     movwf PCLATH
     movf RESULTHI,W
     call LOINTERTABLE ;Put nr of units
     movwf LOINTERVAL ;into LOINTERVAL store.

;Go through off-time counts - MID, UNIT

MIDTIME ;Deals with number of FFs in off-time
LOOP0A
     movf HIINTERVAL,0 ;Put nr of FFs
     movwf HIINTERCNTR ;in HIINTERCNTR.
LOOP1A
     movlw 0xFF ;Put FFh in
     movwf CNTRFF ;CNTRFF
     LOOP2A
     decfsz CNTRFF,1 ;Dec. CNTRFF to zero
     goto LOOP2A ;with inner loop
     decfsz HIINTERCNTR,1 ;Dec. HIINTERCNTR until nr of
     goto LOOP1A ;FFs is zero.

UNITIME ;Deals with lower byte in off-time
     movf LOINTERVAL,0 ;Put LOINTERVAL (nr of UNITS)
     movwf LOINTERCNTR ;in LOINTERCNTR.
LOOP1B
     decfsz LOINTERCNTR,1 ;Decrement LOINTERCNTR
     goto LOOP1B ;until it is zero.
     decfsz LEVCNTR,1 ;Dec. LEVCNTR
     goto NEXT_LEVEL ;Loop for next voltage level
     goto LEVEL_SET ;Loop for next half-cycle

     ORG 0x100
LEVTABLE
     addwf PCL,1
     retlw 0Fh ;
     retlw 1Ah ;
     retlw 1Eh
     retlw 1Ah
     retlw 0Fh
     retlw 00h

     ORG 0x200
HIINTERTABLE
     addwf PCL,1
     retlw 0xD9 ;These values
     retlw 0x6C ;have been
     retlw 36h ;set for
     retlw 24h ;half
     retlw 1Bh ;cycle
     retlw 15h ;times.

     ORG 0x300
LOINTERTABLE
     addwf PCL,1
     retlw 03h ;These values
     retlw 81h ;have been
     retlw 40h ;set for
     retlw 2Bh ;half
     retlw 20h ;cycle
     retlw 0xB3 ;times.
 
     end
 
Last edited:

Thread Starter

Old Frank

Joined Jul 23, 2016
17
Mercy buckets, John (as the French don't say).
I'd removed most of the look-up tables to save space on the website and the "end" with it. The way I've been using Assembler has worked (almost) perfectly with the K150 & Oshonsoft, so I just kept doing it. I'd started with a Velleman 4084 (or something like that) but the K150 was easier to use.
I'll go over it this evening, when SWMBO permits.
Many thanks again.
Frank
 

jpanhalt

Joined Jan 18, 2008
11,088
The tables weren't a problem at all. The problems were getting the correct chip number, formatting the code, and the configuration. For whatever reason, MPLab 8.92 didn't like the bit names. That could also have been a case sensitivity issue. When I test code like this, I usually just do it as a "Quickbuild" and don't set up a project.

John
 

Thread Starter

Old Frank

Joined Jul 23, 2016
17
I think you should check this out How to burn Hex File using PICKit3
They have explained in detail how to do that.
Sorry, but it doesn't help because it leaves out too much. I need either someone sitting next to me to show each step from the start, or instructions that have been B.S.I. tested (where B.S.I. stands for "British Standard Idiot"). E.g. the instructions refer to selecting "Project Wizard", but there's no "Project Wizard" option. Perhaps the reference was left over from an earlier version.
 
Top