Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th December 2007, 08:10 PM   (permalink)
Default Help needed ASM to HEX with MPLAB

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
Attached Files
File Type: txt Moodloop Frequency Generator.txt (8.2 KB, 24 views)
Virus is offline  
Old 10th December 2007, 09:33 PM   (permalink)
Default

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
Diver300 is offline  
Old 10th December 2007, 11:20 PM   (permalink)
Default

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2007, 12:21 AM   (permalink)
Default

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
Pommie is online now  
Old 11th December 2007, 11:20 AM   (permalink)
Default

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
Virus is offline  
Old 11th December 2007, 11:41 AM   (permalink)
Default

Not only should it, it does!. However, if it reports an error, the HEX file won't be created.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2007, 11:53 AM   (permalink)
Default

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
Virus is offline  
Old 11th December 2007, 12:02 PM   (permalink)
Default

Don't know?, I never use MPLAB, I just use the assemble MPASM directly.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2007, 12:04 PM   (permalink)
Default

Nigel

Thanx

Virus

Last edited by Virus; 11th December 2007 at 12:10 PM.
Virus is offline  
Old 11th December 2007, 12:10 PM   (permalink)
Default

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2007, 12:16 PM   (permalink)
Default

Quote:
Originally Posted by Virus
Nigel

Thanx

Virus
Use the 'VIEW' menu option for 'Program Memory' to see the hex file.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Old 11th December 2007, 12:24 PM   (permalink)
Default

Thanx Guys

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

Thanx

Virus
Virus is offline  
Old 11th December 2007, 08:45 PM   (permalink)
Default

Guys

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

A blessed Christmas to you all.

Virus
Virus is offline  
Old 11th December 2007, 09:34 PM   (permalink)
Default

Quote:
Originally Posted by Virus
Guys

Thanx for all the help, programmed the chip, and it seems to run OK.
Well done!
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 12th December 2007, 02:32 AM   (permalink)
Default

Quote:
Thanx for all the help, programmed the chip, and it seems to run OK
Have you experienced any mood changes?
Brevor is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
PIC16F84A - ASM to HEX Mihindu_gajaba Micro Controllers 3 22nd November 2007 05:30 PM
Question about Inchworm+ Quan Micro Controllers 54 28th October 2007 01:21 AM
PIC16F877A TX data to PC via serial cable derrick826 Micro Controllers 21 8th October 2007 02:28 PM
Need help badly on Inchworm and MPLAB thushy Micro Controllers 14 11th March 2007 07:05 PM
16F88 and MPLAB Help needed GRC Micro Controllers 28 28th December 2006 01:24 AM



All times are GMT. The time now is 01:03 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker