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.

starting Nigel's tutorial, have questions

Status
Not open for further replies.

charlie_r

Member
Ok, so all of you know, I am a noob with pics. I am trying to figure out exactly what does what in .asm files. I am using MPLAB IDE, and am coming up with a few errors.

First Question: How does mplab determine line #s? Are blank lines included in the numbering sequence? Are comment lines included as well?

Second Question: Does anyone know where to find a listing and explanation of the error codes?

Here is the code, basically copied from the tut with my own comments to ensure that I am understanding what I am doing:

Code:
;*******************************************************************************
		;Tutorial 1.1 - Nigel Goodwin 2002
		;First try at writing code, basically copying nigels code, with my own
		;understanding of what is being done
		title "blink led"
		list p=16F628A
		#include "p16F628A.inc"

;************************** config bits *****************************************

		__config 0x2118 

;************************** the program setup info ******************************

	org	0x0000			;sets the program origin, where it starts from
	
	movlw	0x07			;puts Literal value in Working register
	movwf	CMCON			;moves value in W register to CoMparator CONtrol
					;turning off comparators

	bsf	STATUS,		RP0	;Bit Set File selecting bank 1
	movlw	b 00000000		;moves Binary number to Working Register
	movwf	TRISB			;sets port b to outputs-TRIState port B
	movwf	TRISA			;sets port a to outputs
	bcf	STATUS,		RP0	;Bit Clear File clears the status register,
					;resetting to bank0

;************************* the actual program ***********************************

loop					;program section name

	movlw	0xff			;sets value of (b)'11111111' into Working register
	movwf	PORTA			;copies W value to porta and portb turning all pins
	movwf	PORTB			;setting the pins logic high

	nop				;No OPeration, basically telling the controller to
	nop				;go on to the next step, taking up the extra clock
					;cycles that the goto command needs

	movlw	0x00			;sets value of (b)'00000000' into the Working register
	movwf	PORTA			;copies W value to ports, turning them off again
	movwf	PORTB			;
	goto	loop			;tells it to return to the top,note: this is a never
					;ending cycle killed only by removing power

	end				;needed for proper parsing, even if it does nothing

Here are the errors that are being generated:

Error[113] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Symbol not previously defined (b)
Error[112] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Missing operator
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 23 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 24 : Register in operand not in bank 0. Ensure that bank bits are correct

Any help is appreciated!
 
Ok, so all of you know, I am a noob with pics. I am trying to figure out exactly what does what in .asm files. I am using MPLAB IDE, and am coming up with a few errors.

First Question: How does mplab determine line #s? Are blank lines included in the numbering sequence? Are comment lines included as well?

Second Question: Does anyone know where to find a listing and explanation of the error codes?

Here is the code, basically copied from the tut with my own comments to ensure that I am understanding what I am doing:

Code:
;*******************************************************************************
		;Tutorial 1.1 - Nigel Goodwin 2002
............

Here are the errors that are being generated:

Error[113] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Symbol not previously defined (b)
Error[112] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Missing operator
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 23 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 24 : Register in operand not in bank 0. Ensure that bank bits are correct

Any help is appreciated!


In line 22
movlw b 00000000 ;moves Binary number to Working
this should be
movlw b'00000000'

this has caused 2 errors.
other two are only messages
and this could be avoided by adding an instruction above or below config word
errorlevel -302

query1: There is a provsion in MPLAB that line numbers can be siaplayed
the line numbers of .asm file include the blank, lines also. as the compilation happens in an orderly fashion, it is not a problem for the MPLAB to log the line number having error.

Query2. click following sequence in MPLAB--help-topics-(language tools)-MPASM Assembler-(select again)MPASM Assembler-Errors,Warnings, Messages, and Limitations

there you get the listings.
 
Last edited:
First Question: How does mplab determine line #s? Are blank lines included in the numbering sequence? Are comment lines included as well?

I believe blank lines are not included. Nor are comments. Since both of these contain no information for the compiler.

Second Question: Does anyone know where to find a listing and explanation of the error codes?

Hmm, perhaps MPLAB's help file? I've never used any error lists, just opened the *.lst file in MPLAB, and gone through it...as any errors are highlighted, with the error code, and its meaning.


Error[113] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Symbol not previously defined (b)
Error[112] E:\1STPROGWINPIC\BLINKLED.ASM 22 : Missing operator
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 23 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] E:\1STPROGWINPIC\BLINKLED.ASM 24 : Register in operand not in bank 0. Ensure that bank bits are correct

Ok. So going through them...
113: probably a typo! If you have named a register, or a constant say 'first1', but refer to it as 'first', of course the compiler looks for something called 'first'. If there is only one reference to this, then it points out you haven't labelled anything as such.

112: Many, if not most instructions require an operator. This is usually a 0, or 1 after a register file label to determine where its location goes, either in W (the working register) or F, goes back into the file register it came from. For example.... if one was to increment a counter, you'll want to increment it and put the result BACK into that register...otherwise the contents of that register will stay the same and you'll end up with (file register value + 1) in the working register.

Examples:
Incf Counter, f - with f being the operator.
Incf Counter, 1 - a value as one doe sthe same thing (compiler will accept both)

Movf Counter,w - simply moves the contents of 'counter' into W.
Movf Counter - will generate the 112 error.

It seems you have missed this off.


302: A very common error. When refering to a file register you must be in the correct bank, usually bank 0, or 1. You can either change these bits manually by using 'bsf', and 'bcf' to select the bank, or, most conveniently use a built-in MPLAB macro. The syntax for the macro is:

banksel <name of register>

This will compile to the bcf/bsf instructions to select the correct bank for the file register.

Example:

movlw 0x44 ; move value 44h into W.
banksel ADCON1 ; move to correct bank to deal with ADCON1
movwf ADCON1 ; move our 44h in the W reg, into ADCON1.

Hope this helps

Blueteeth
 
Thank you mvs sarma and blueteeth,

I didn't see that I had ommited the single quotes around the binary value.

@ mvs: A new question arises though, about the "errorlevel -302" being added to the config section. What exactly does this do? and would I find the answer in the datasheet?

@ blueteeth: Thank you for a good explanation. Now if I can remember all this stuff I'm learning.......
 
Last edited:
I believe blank lines are not included. Nor are comments. Since both of these contain no information for the compiler.
..................

Hope this helps
Blueteeth
the messages are referred to asm file line numbers
i have enabled lione numbers in MPLAB

i checked it counting all lines whether blank or starting with a ";"

please check by actually loading and deliberately creating an error.
 
Thank you mvs sarma and blueteeth,

I didn't see that I had ommited the single quotes around the binary value.

@ mvs: A new question arises though, about the "errorlevel -302" being added to the config section. What exactly does this do? and would I find the answer in the datasheet?

@ blueteeth: Thank you for a good explanation. Now if I can remember all this stuff I'm learning.......
errorlevel is added aline next to __config line and NOT in config line

you please read the MPAsm user manual
you can get many more such things
similarly a general reading of the concerned manual like Assembler manual etc, really helps clarify things in advance.
however, there is lot of help provided and you can go to them at the needy hour.
 
Thanks for the help guys!

I do have another question though.

Am I right in thinking that the c7 in 0xc7 refers to 11000111 in binary?
Meaning the first digit=first four in a binary 8 bit word and the second the last four?
 
Am I right in thinking that the c7 in 0xc7 refers to 11000111 in binary?
Meaning the first digit=first four in a binary 8 bit word and the second the last four?

Yes, and like decimal if there is only 1 digit it is the least significant. So, 0x7, 0x07, b'00000111' and b'111' are all equivalent.

Mike.
 
Yes, and like decimal if there is only 1 digit it is the least significant. So, 0x7, 0x07, b'00000111' and b'111' are all equivalent.

Mike.
b'111' equal to b'0000111' is a great input Pommie. Thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top