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
 
Thread Tools Display Modes
Old 27th March 2008, 04:57 PM   (permalink)
Question Basic 16F84

I am using 16F84 microchip,
Code:
;EQUATES SECTION

TMR0		EQU	1
STATUS		EQU	3
PORTA		EQU	5
POTRB		EQU	6
TRISA		EQU	85H
TRISB		EQU	86H
OPTION_R	EQU	81H
ZEROBIT		EQU	2
COUNT		EQU	0CH

;******************************************************
LIST 	P=16F84;
ORG	0;
GOTO	start;

;******************************************************

;CONFIGURATION BITS

__CONFIG H'3FF0'

;*********************************************************

;SUBROUTINES SECTION

;1 SECOND DELAY

DELAY1		CLFR		TMR0
LOOPA		MOVF		TMR0,W
		SUBLW		.32
		BTFSS		STATUS,
				ZEROBIT
		GOTO		LOOPA
		RETLW		0

;0.5 SECOND DELAY
DELAYP5		CLFR		TMR0
LOOPB		MOVF		TMR0,W
		SUBLW		.16
		BTFSS		STATUS,
				ZEROBIT
		GOTO		LOOPB
		RETLW		0

;*****************************************************************

;CONFIGURATION SECTION

start 	BSF			STATUS,5
		MOVLW		B'00011111'
		MOVWF		TRISA
		MOVLW		B'00000000'
		MOVWF		TRISB
		MOVLW		B'00000111'
		MOVWF		OPTION_R
		BCF			STATUS,5
		CLRF		PORTA
		CLRF		PORTB


;**********************************************************************

;PROGRAM STARTS NOW

END
These are the codes, I borrowed these codes from a book. I am trying to learn how to build these codes.

Using Mplab i press control+F10 and these are the error that i faced 27error!
Code:
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Hisham\Desktop\Spring 2008\Design 2\Design II modified\Open loop\Test.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 20:58:34 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84 "C:\Documents and Settings\Hisham\Desktop\Hesham.asm" /l"Hesham.lst" /e"Hesham.err" /o"Hesham.o" /d__DEBUG=1
Warning[205] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 14 : Found directive in column 1. (LIST)
Warning[205] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 15 : Found directive in column 1. (ORG)
Warning[203] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 16 : Found opcode in column 1. (GOTO)
Warning[205] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 22 : Found directive in column 1. (__CONFIG)
Error[122]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 30 : Illegal opcode (CLFR)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 31 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 32 : Executable code and data must be defined in an appropriate section
Error[128]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 33 : Missing argument(s)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 33 : Executable code and data must be defined in an appropriate section
Warning[207] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 34 : Found label after column 1. (ZEROBIT)
Error[115]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 34 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 35 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 36 : Executable code and data must be defined in an appropriate section
Error[122]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 39 : Illegal opcode (CLFR)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 40 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 41 : Executable code and data must be defined in an appropriate section
Error[128]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 42 : Missing argument(s)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 42 : Executable code and data must be defined in an appropriate section
Warning[207] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 43 : Found label after column 1. (ZEROBIT)
Error[115]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 43 : Duplicate label ("ZEROBIT" or redefining symbol that cannot be redefined)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 44 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 45 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 51 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 52 : Executable code and data must be defined in an appropriate section
Message[302] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 53 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 53 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 54 : Executable code and data must be defined in an appropriate section
Message[302] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 55 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 55 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 56 : Executable code and data must be defined in an appropriate section
Message[302] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 57 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 57 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 58 : Executable code and data must be defined in an appropriate section
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 59 : Executable code and data must be defined in an appropriate section
Error[113]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 60 : Symbol not previously defined (PORTB)
Error[152]   C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 60 : Executable code and data must be defined in an appropriate section
Warning[205] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 67 : Found directive in column 1. (END)
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Hisham\Desktop\Spring 2008\Design 2\Design II modified\Open loop\Test.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 20:58:35 2008
FAILED
----------------------------------------------------------------------
Any solution, i am looking forard for help
uaefame is offline  
Reply With Quote
Old 27th March 2008, 05:02 PM   (permalink)
Default

Quote:
Originally Posted by uaefame
Any solution, i am looking forard for help
I have just the thing for you. On my new web-site there's a simple newbie circuit and some easy asm code to show you how to get started properly. And there's photos of the breadboard too. You can take it from there.
http://www.ghmicro.com/index.php/pic...84-simple-demo
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now  
Reply With Quote
Old 27th March 2008, 05:14 PM   (permalink)
Default

Woops. I just noticed that my schematic didn't match the photos. It would work just fine, but might confuse you since they didn't match. I just changed it to match.

So if you just looked at it or downloaded it, refresh your browser by going to the page and hitting F5 and go look at it or download it again.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 27th March 2008 at 05:18 PM.
futz is online now  
Reply With Quote
Old 27th March 2008, 05:36 PM   (permalink)
Default

And here's your code cleaned up and with many corrections. There were misspellings and indentation errors and things that were done just plain strangely. It now assembles with no errors. Ignore those two warnings. They're taken care of in the code, but it warns you anyway.

By the way, this code does nothing yet. Just sets a few registers and falls into empty memory. Then it runs thru the nops (empty memory) and rolls over and starts again... and goes again and again and again, doing nothing.
Code:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

	cblock	0x0c
	COUNT
	endc

ZEROBIT	EQU	2

	org	0
	goto	start

;SUBROUTINES SECTION

;1 SECOND DELAY
DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,ZEROBIT
	goto	LOOPA
	retlw	0

;0.5 SECOND DELAY
DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,ZEROBIT
	goto	LOOPB
	retlw	0

;*********************
;CONFIGURATION SECTION

start
	banksel	TRISA		;bank 1
	movlw	B'00011111'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_REG
	banksel	PORTA		;bank 0
	clrf	PORTA
	clrf	PORTB

;PROGRAM STARTS NOW

	end
And don't use "OPTION_R". Use the proper equates from the datasheet and the include file. The correct thing to use in place of "OPTION_R" is "OPTION_REG".
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 27th March 2008 at 06:16 PM.
futz is online now  
Reply With Quote
Old 27th March 2008, 05:49 PM   (permalink)
Default

Thank alot, Most of the error disapear thanks alot.
Code:
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Hisham\Desktop\Spring 2008\Design 2\Design II modified\Open loop\Test.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 21:47:33 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84 "C:\Documents and Settings\Hisham\Desktop\Hesham.asm" /l"Hesham.lst" /e"Hesham.err" /o"Hesham.o" /d__DEBUG=1
Message[302] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 38 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\DOCUMENTS AND SETTINGS\HISHAM\DESKTOP\HESHAM.ASM 40 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPLink.exe" "..\..\..\..\..\..\..\Program Files\Microchip\MPASM Suite\LKR\16f84.lkr" "Hesham.o" /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"Test.cof" /M"Test.map" /W
MPLINK 4.15, Linker
Copyright (c) 2007 Microchip Technology Inc.
Error - section '.org_0' can not fit the absolute section. Section '.org_0' start=0x00000000, length=0x0000002e
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Debug build of project `C:\Documents and Settings\Hisham\Desktop\Spring 2008\Design 2\Design II modified\Open loop\Test.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 21:47:35 2008
FAILED
----------------------------------------------------------------------
This error was notice
uaefame is offline  
Reply With Quote
Old 27th March 2008, 05:57 PM   (permalink)
Default

hi,
I would suggest you create a folder on your hard drive thats dedicated to your assembler output.

This will make your error messages easier to read and the assembled files more accessible.

You should add near the top of your program.
errorlevel -302

this will stop the 'Bank' warning messages
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Reply With Quote
Old 27th March 2008, 05:59 PM   (permalink)
Default

Quote:
Originally Posted by uaefame
This error was notice
How is your Project set up? Here's what I get when I assemble:
Code:
Release build of project `C:\MCU\16F84A\blinky\blinky.mcp' started.
Thu Mar 27 10:57:34 2008
----------------------------------------------------------------------
Make: The target "C:\MCU\16F84A\blinky\uae_test.o" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84 "uae_test.asm" /l"uae_test.lst" /e"uae_test.err"
Message[302] C:\MCU\16F84A\BLINKY\UAE_TEST.ASM 38 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\MCU\16F84A\BLINKY\UAE_TEST.ASM 40 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\MCU\16F84A\BLINKY\UAE_TEST.ASM 42 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Loaded C:\MCU\16F84A\blinky\uae_test.cod.
----------------------------------------------------------------------
Release build of project `C:\MCU\16F84A\blinky\blinky.mcp' succeeded.
Thu Mar 27 10:57:35 2008
----------------------------------------------------------------------
BUILD SUCCEEDED
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now  
Reply With Quote
Old 27th March 2008, 06:00 PM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi,
I would suggest you create a folder on your hard drive thats dedicated to your assembler output.

This will make your error messages easier to read and the assembled files more accessible.

You should add near the top of your program.
errorlevel -302

this will stop the 'Bank' warning messages
Like this:
Code:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
	errorlevel -302

	cblock	0x0c
	COUNT
	endc

ZEROBIT	EQU	2

	org	0
	goto	start

;SUBROUTINES SECTION

;1 SECOND DELAY
DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,ZEROBIT
	goto	LOOPA
	retlw	0

;0.5 SECOND DELAY
DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,ZEROBIT
	goto	LOOPB
	retlw	0

;*********************
;CONFIGURATION SECTION

start
	banksel	TRISA		;bank 1
	movlw	B'00011111'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_REG
	banksel	PORTA		;bank 0
	clrf	PORTA
	clrf	PORTB

;PROGRAM STARTS NOW

	end
Code:
Release build of project `C:\MCU\16F84A\blinky\blinky.mcp' started.
Thu Mar 27 11:00:46 2008
----------------------------------------------------------------------
Make: The target "C:\MCU\16F84A\blinky\uae_test.o" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84 "uae_test.asm" /l"uae_test.lst" /e"uae_test.err"
Loaded C:\MCU\16F84A\blinky\uae_test.cod.
----------------------------------------------------------------------
Release build of project `C:\MCU\16F84A\blinky\blinky.mcp' succeeded.
Thu Mar 27 11:00:47 2008
----------------------------------------------------------------------
BUILD SUCCEEDED
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 27th March 2008 at 06:16 PM.
futz is online now  
Reply With Quote
Old 27th March 2008, 06:22 PM   (permalink)
Default

I did as ericgibbs told me, I change the file path.

Code:
Debug build of project `D:\Openloop\test.mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 22:18:04 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "D:\Openloop\test.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84 "C:\Documents and Settings\Hisham\Desktop\hesham2.asm" /l"hesham2.lst" /e"hesham2.err" /o"hesham2.o" /d__DEBUG=1
Executing: "C:\Program Files\Microchip\MPASM Suite\MPLink.exe" "C:\Program Files\Microchip\MPASM Suite\LKR\16f84.lkr" "hesham2.o" /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"test.cof" /M"test.map" /W
MPLINK 4.15, Linker
Copyright (c) 2007 Microchip Technology Inc.
Error - section '.org_0' can not fit the absolute section. Section '.org_0' start=0x00000000, length=0x0000002e
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Debug build of project `D:\Openloop\test.mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Thu Mar 27 22:18:05 2008
FAILED
I can't figure out the error.

I am using linker file 16F84.lkr
uaefame is offline  
Reply With Quote
Old 27th March 2008, 06:25 PM   (permalink)
Default

Quote:
Originally Posted by uaefame
I can't figure out the error.

I am using linker file 16F84.lkr
If you're assembling just one asm source file you don't need any linker file.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now  
Reply With Quote
Old 27th March 2008, 06:29 PM   (permalink)
Default

OMG, Problem solved i can't belive it.
I assembled for the first time.
OMG.
Thanks everyone
I just removed the linker and it worked thanks alot.
uaefame is offline  
Reply With Quote
Old 27th March 2008, 06:57 PM   (permalink)
Default

Thanks everyone specially "futz" For helping me around.
I am looking for a way to improve these codes

Code:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _LP_OSC
	errorlevel -302

	cblock	0x0c
	COUNT
	endc

ZEROBIT	EQU	2

	org	0
	goto	start;

;SUBROUTINES SECTION

;1 SECOND DELAY
DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,ZEROBIT
	goto	LOOPA
	retlw	0

;0.5 SECOND DELAY
DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,ZEROBIT
	goto	LOOPB
	retlw	0

;*********************
;CONFIGURATION SECTION

start
	banksel	TRISA		;bank 1
	movlw	B'00000010'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_REG
	banksel	PORTA		;bank 0
	clrf	PORTA
	clrf	PORTB

;program starts here
begin	bsf	PORTB,0
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		bcf PORTB,0;
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second
		call DELAY1; wait 1second	
		goto begin		
	end
At the end, Some codes keep repeating "call delay1" to have a delay for 1 second how can i increase the delay without repeating the same line again and again
uaefame is offline  
Reply With Quote
Old 27th March 2008, 07:01 PM   (permalink)
Default

Quote:
Originally Posted by uaefame
At the end, Some codes keep repeating "call delay1" to have a delay for 1 second how can i increase the delay without repeating the same line again and again
Make a longer delay. Have a look at the piclist delay generator.

The d1, d2, d3, d4 variables go in the cblock.

There are better ways, but I use it all the time. It's quick and easy, and I don't have to think too much about it.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now  
Reply With Quote
Old 27th March 2008, 07:38 PM   (permalink)
Default

Great way and i will thanks you all day.
Code:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _LP_OSC
	errorlevel -302

	cblock	0x0c
	COUNT
	endc

ZEROBIT	EQU	2

	org	0
	goto	start;

;SUBROUTINES SECTION

;1 SECOND DELAY
DELAY1	clrf	TMR0
LOOPA	movf	TMR0,W
	sublw	.32
	btfss	STATUS,ZEROBIT
	goto	LOOPA
	retlw	0

;0.5 SECOND DELAY
DELAYP5	clrf	TMR0
LOOPB	movf	TMR0,W
	sublw	.16
	btfss	STATUS,ZEROBIT
	goto	LOOPB
	retlw	0

; Delay = 60 seconds
; Clock frequency = 0.032 MHz

; Actual delay = 60 seconds = 480000 cycles
; Error = 0 %

	cblock
	d1
	d2
	d3
	endc

			;479995 cycles
	movlw	0xDA
	movwf	d1
	movlw	0x0C
	movwf	d2
	movlw	0x02
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;5 cycles
	goto	$+1
	goto	$+1
	nop


;*********************
;CONFIGURATION SECTION

start
	banksel	TRISA		;bank 1
	movlw	B'00000010'
	movwf	TRISA
	movlw	B'00000000'
	movwf	TRISB
	movlw	B'00000111'
	movwf	OPTION_REG
	banksel	PORTA		;bank 0
	clrf	PORTA
	clrf	PORTB

;program starts here
begin	bsf	PORTB,0
		bcf PORTB,0;
		goto begin		
	end
How can i call this delay, at the end of the program bcf PORTB,0; after it i want a delay of 60second
uaefame is offline  
Reply With Quote
Old 27th March 2008, 07:41 PM   (permalink)
Default

Dude, don't make a second cblock. Put the variables in the first one.
Like this:
Code:
	LIST	P=PIC16F84
	#INCLUDE "P16F84.INC"
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _LP_OSC
	errorlevel -302

	cblock	0x0c
	COUNT,d1,d2,d3
	endc

ZEROBIT	EQU	2

	org	0
	goto	start;
Also, that second cblock you made has nothing to tell it where to place the variables. It probably assumes zero and kills three of your SFR's. This means instant crash, and the program does nothing. Look at the above code. See where it tells the assembler to put the cblock at 0x0c, which is the start of user RAM in the F84.

To call the delay, you have to put a label at the beginning of the delay routine and a return at the end. Then use
Code:
	call	delay
to call the subroutine.

The delay routine would look like
Code:
delay	movlw	0xDA
	movwf	d1
	movlw	0x0C
	movwf	d2
	movlw	0x02
	movwf	d3
Delay_0	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0
	return
The delay generator will put the label and the return for you if you tell it to Generate Routine and tell it what label you want on your routine.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 27th March 2008 at 08:36 PM.
futz is online now  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Visual Basic for Electronics Engineering Applications ThermalRunaway Electronic Books 22 27th August 2008 07:40 PM
It is BASIC or is it BABL 3v0 Micro Controllers 22 7th May 2007 02:08 PM
free pic basic complier dstich Micro Controllers 7 1st August 2006 07:13 PM
Assembly to Basic Coding AZdave Micro Controllers 3 23rd January 2005 02:27 PM
PIC basic and Basic stamp Cyborg Micro Controllers 5 21st April 2004 08:44 AM



All times are GMT. The time now is 06:28 AM.


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