Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help needed ASM to HEX with MPLAB

Status
Not open for further replies.

Virus

New Member
Hi guys

I have built the Mood Loop project published in EPE issue 2000.08.
Got hold of all the components with no hassle and built the unit, downloaded the .asm file from epe.com (file attached). I have tried using MPLAB but I can not get it to compile a hex file successfully.

I do not have any experience in programming. Other projects that I have built the hex code was already available. I don’t think the code is in error, must be my 10 thumbs with MPLAB.

This is the error :
Error[122] C:\DOCUMENTS AND SETTINGS\DANIE\DESKTOP\MOOD LOOP\UNTITLED.ASM 13 : Illegal opcode (.EQU)
Should I use other software ?

Has anyone els tried to compile the hex code for this project, successfully?

Your advice will be much appreciated.

Thanks

Virus
 

Attachments

  • Moodloop Frequency Generator.txt
    8.2 KB · Views: 480
I think that assembly language is for an older version of MPLAB

Try without the .

so it should read:-

ctr0 EQU 0x0C

The : after the labels aren't needed and they might cause a problem.

so an example label should read:-

dlytbl addwf pcl,f

Also, if you put in #include p16f84.asm you can get rid of all the general equates.

A PIC16F627A is cheaper and better than a PIC16F84. All you need to do is change the program specific includes to start at 0x20
 
A lot of the older EPE projects don't use MPLAB/MPASM, they use a shareware assembler configured for PIC (MASM). If you download the EPE PIC Toolkit it has options for converting the source to work with MicroChip assemblers.
 
There was a couple of things that would stop the file working in MPLAB. Things like assuming the radix would be decimal and having no code at location 0.

Anyway, this should now compile.

Mike.

Code:
;Moodloop Frequency Generator
;Andy Flind 1/12/99     
;For PIC16F84 or PIC16C84
;For 4.00MHz xtal       
;Configuration          
;Oscillator  XT         
;Watchdog timer  NO     
;Power-up timer  YES    

		radix	dec
                        
#DEFINE         page0   BCF status,5
#DEFINE         page1   BSF status,5
                        	
status          EQU     0x03             ;general equates
portA           EQU     0x05
trisA           EQU     0x05
portB           EQU     0x06
trisB           EQU     0x06
pcl             EQU     0x02
rtcc            EQU     0x01
;option          EQU     0x01
intcon          EQU     0x0B
f               EQU     0x01
w               EQU     0x00
z               EQU     0x02
                        
ctr0            EQU     0x0C             ;program specific equates
ctr1            EQU     0x0D
ptr             EQU     0x0E
freq            EQU     0x1F
         
		org	0x0000
		goto	start
               
                org     0x0004           ;interrupt vector
        ;        org     0x0005           ;start of program
                        
        ;        goto    start
;=====================================================
dlytbl          addwf   pcl,f
                goto    dly0
                goto    dly1
                goto    dly2
                goto    dly3
                goto    dly4
                goto    dly5
                goto    dly6
                goto    dly7
                goto    dly8
                goto    dly9
                goto    dly10
                goto    dly11
                goto    dly12
                goto    dly13
                goto    dly14
                goto    dly15
;=====================================================
start           clrf    portA           ;initialise for operation
                clrf    portB
                page1   
                movlw   b'11111111'
                movwf   trisA           ;portA all input
                clrf    trisB           ;portB all output
                page0   
                clrf    portA
                clrf    portB
;=====================================================
                comf    portA,w         ;get the switch pattern
                andlw   15              ;check validity
                movwf   ptr             ;put it into ptr
;=====================================================
cycle           bsf     portB,0         ;output sequence step 1
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        
                nop                     ;output sequence step 2
                nop                     ;2 nops compensate for
                bsf     portB,1         ;the "return" before step 1
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 3
                nop      
                bsf     portB,2         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 4
                nop      
                bsf     portB,3         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 5
                nop      
                bsf     portB,4         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 6
                nop      
                bsf     portB,5         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 7
                nop      
                bsf     portB,6         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 8
                nop      
                bsf     portB,7         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 9
                nop     
                bcf     portB,7         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        
                nop                     ;output sequence step 10
                nop      
                bcf     portB,6         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 11
                nop      
                bcf     portB,5         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 12
                nop      
                bcf     portB,4         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 13
                nop      
                bcf     portB,3         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 14
                nop      
                bcf     portB,2         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 15
                nop      
                bcf     portB,1         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                nop                     ;output sequence step 16
                nop      
                bcf     portB,0         
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfss   status,z
                goto    start
                movf    ptr,w
                call    dlytbl
                        	
                goto    cycle           ;and do sequence again
;=====================================================
dly0            movlw   176             ;1st frequency
                movwf   ctr1
t0a             movlw   117
                movwf   ctr0
t0              decfsz  ctr0,f
                goto    t0
                decfsz  ctr1,f
                goto    t0a
                nop     
                nop     
                nop     
                return                  ;for 1.0Hz
;=====================================================
dly1            movlw   57              ;2nd frequency
                movwf   ctr1
t1a             movlw   227
                movwf   ctr0
t1              decfsz  ctr0,f
                goto    t1
                decfsz  ctr1,f
                goto    t1a
                nop     
                return                  ;for 1.6Hz
;=====================================================
dly2            movlw   78              ;3rd frequency
                movwf   ctr1
t2a             movlw   120
                movwf   ctr0
t2              decfsz  ctr0,f
                goto    t2
                decfsz  ctr1,f
                goto    t2a
                return                  ;for 2.2Hz
;=====================================================
dly3            movlw   48              ;4th frequency
                movwf   ctr1
t3a             movlw   95
                movwf   ctr0
t3              decfsz  ctr0,f
                goto    t3
                decfsz  ctr1,f
                goto    t3a
                return                  ;for 4.5Hz
;=====================================================
dly4            movlw   186             ;5th frequency
                movwf   ctr1
t4a             movlw   19
                movwf   ctr0
t4              decfsz  ctr0,f
                goto    t4
                decfsz  ctr1,f
                goto    t4a
                nop     
                return                  ;for 5.5Hz
;=====================================================
dly5            movlw   21              ;6th frequency
                movwf   ctr1
t5a             movlw   151
                movwf   ctr0
t5              decfsz  ctr0,f
                goto    t5
                decfsz  ctr1,f
                goto    t5a
                nop     
                return                  ;for 6.5Hz
;=====================================================
dly6            movlw   27              ;7th frequency
                movwf   ctr1
t6a             movlw   97
                movwf   ctr0
t6              decfsz  ctr0,f
                goto    t6
                decfsz  ctr1,f
                goto    t6a
                return                  ;for 7.83Hz (schumann res.)
;=====================================================
dly7            movlw   23              ;8th frequency
                movwf   ctr1
t7a             movlw   89
                movwf   ctr0
t7              decfsz  ctr0,f
                goto    t7
                decfsz  ctr1,f
                goto    t7a
                return                  ;for 10.0Hz
;=====================================================
dly8            movlw   149             ;9th frequency
                movwf   ctr1
t8a             movlw   11
                movwf   ctr0
t8              decfsz  ctr0,f
                goto    t8
                decfsz  ctr1,f
                goto    t8a
                nop     
                return                  ;for 11.3Hz
;=====================================================
dly9            movlw   33              ;10th frequency
                movwf   ctr1
t9a             movlw   49
                movwf   ctr0
t9              decfsz  ctr0,f
                goto    t9
                decfsz  ctr1,f
                goto    t9a
                return                  ;for 12.5Hz
;=====================================================
dly10           movlw   21              ;11th frequency
                movwf   ctr1
t10a            movlw   48
                movwf   ctr0
t10             decfsz  ctr0,f
                goto    t10
                decfsz  ctr1,f
                goto    t10a
                return                  ;for 20.0Hz
;=====================================================
dly11           movlw   4               ;12th frequency
                movwf   ctr1
t11a            movlw   234
                movwf   ctr0
t11             decfsz  ctr0,f
                goto    t11
                decfsz  ctr1,f
                goto    t11a
                return                  ;for 22.0Hz
;=====================================================
dly12           movlw   209             ;13th frequency (test)
                movwf   ctr1
t12a            movlw   198
                movwf   ctr0
t12             decfsz  ctr0,f
                goto    t12
                decfsz  ctr1,f
                goto    t12a
                nop     
                return                  ;for 0.5Hz
;=====================================================
dly13           movlw   14              ;14th frequency (test)
                movwf   ctr1
t13a            movlw   28
                movwf   ctr0
t13             decfsz  ctr0,f
                goto    t13
                decfsz  ctr1,f
                goto    t13a
                nop     
                return                  ;for 50.0Hz
;=====================================================
dly14           movlw   255             ;15th frequency (test, all high)
                movwf   portB
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfsc   status,z
                goto    dly14           ;repeat until switches change
                return  
;=====================================================   
dly15           clrf    portB           ;16th frequency (test, all low)
                comf    portA,w
                andlw   15
                xorwf   ptr,w
                btfsc   status,z
                goto    dly15           ;repeat until switches change
                return  
;=====================================================
                        	
                END
 
Thanks for the help, Guys

Pommie, the code compiled ok. Now in laymen terms, how do I get a HEX file out of this ?

Should it not generate the hex file when you compile it?

Thanks again

Virus:)
 
Thanx Nigel

It complied with 0 errors ?

So, t is not necessary to tel MPLAB that you want a HEX file it does it automatically

Virus
 
Nigel

Thanx

Virus
 
Last edited:
Try searching your drive for 'Untitled.hex'.

Although looking at that it doesn't mention a hex file?, but on MPASMWIN there's no option NOT to generate one.

Try running MPASMWIN on it's own, browse to the ASM file, and click 'Assemble', see what happens.
 
Thanx Guys

Got it, made the HEX file, will program the chip tonight, and give feed back.

Thanx

Virus
 
Guys

Thanx for all the help, programmed the chip, and it seems to run OK.

A blessed Christmas to you all.

Virus
 
Help needed EPE ASM to HEX with MPLAB

Hi Guys

Me again with the same problem on a different project.

I have built the hardware for, the PIC-Gen EPE July 2000, about 4 months ago and would like to finish it off. But I have the same problem that MPlab is not compiling the EPE asm code. Once again can any one help please?

Is their a compiler that can compile the code to hex, available from some where on the web, or maybe laying in a computer some where.

Tanks for your help.

Virus

@Brevor

MOOD CHANGES ?, you have no idea how this thing can swing your mind !
 

Attachments

  • PIC-Gen.asm
    22.4 KB · Views: 348
It's not MPASM compatible code, it's written using a Shareware assembler. If you download Toolkit3 from EPE, it includes routines for converting between formats.
 
Hi Nigel

I have looked on the epe site but could not find the link to any one of their toolkits. Will look again !

What is the .obj file ?

Thax Virus
 
Look under 'Downloads' then 'All PIC Microcontroller source codes', there's 'PIC Toolkit TK2' and 'Toolkit TK3 updates', you can also download TASM the assembler they used.
 
Nigel

Thanx, I got it, can I bug you later on, if I don’t get it working ?

(Taking a shot in the dark here) Do you know where they stored their supplementing articles, I can’t find the library link they refer to. There is one on How to get TK3 running under WinXp.

Thanx

Virus
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top