Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How add user defined header file to project

Status
Not open for further replies.

PA3040

Advanced Member level 3
Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,936
Dear All,

I need add continuously use program subroutine as header file to my project folder

Example In Assembly

delay subroutine is using continuously, therefore I need use delay subroutine in separate file and add to main program like we add processor register file (#include <p16f877a.inc>)
Hopefully anybody understand what I need is

My MCU is 16f877a

Language is Assembly

Please advice


Thanks in advance
PA3040
 
Last edited:

Hi,

Back with assembler ?

Example attached.. for 18Fs but think on the 16F you might have to place the #includes at the beginning of your main code with after the list.
 

Attachments

  • delay.rar
    501 bytes · Views: 122
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
dear wp100,
Thanks for the reply
I did it like this and "delay.inc" file include to the project folder
Code:
status		equ		0x03
trisc		equ		0x87
portc		equ		0x07

#include	<p16f877a.inc>
__config 3f39
[COLOR="#FF0000"]#include delay.inc[/COLOR]


start		goto	main
main		call	sys_init
			call	led_on
			
led_on			
loop		movlw	0xff
			movwf	portc
			[COLOR="#FFA07A"]call	delay[/COLOR]
			clrf	portc
			goto	loop

sys_init	bsf		status,5
			clrf	trisc
			bcf		status,5
			return

then following error is occurring, please help

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F877A "test.asm" /l"test.lst" /e"test.err" /d__DEBUG=1
Warning[205] C:\BATCH1\TEST\TEST.ASM 6 : Found directive in column 1. (__config)
Error[113] C:\BATCH1\TEST\DELAY.INC 10 : Symbol not previously defined (d1)
Error[113] C:\BATCH1\TEST\DELAY.INC 12 : Symbol not previously defined (d2)
Error[113] C:\BATCH1\TEST\DELAY.INC 14 : Symbol not previously defined (d1)
Error[113] C:\BATCH1\TEST\DELAY.INC 16 : Symbol not previously defined (d2)
Error[113] C:\BATCH1\TEST\TEST.ASM 17 : Symbol not previously defined (delay)
Message[302] C:\BATCH1\TEST\TEST.ASM 22 : Register in operand not in bank 0. Ensure that bank bits are correct.
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\Batch1\test\test.asm.mcp' failed.
Language tool versions: MPASMWIN.exe v5.36, mplink.exe v4.36, mplib.exe v4.36
Preprocessor symbol `__DEBUG' is defined.
Tue Oct 23 23:46:12 2012
----------------------------------------------------------------------
BUILD FAILED

Thanks in advance
I never forget Assembly
 

Hi,

This should work for you - but check the osc in the config bits XT = 4meg and below
Code:
;status		equ		0x03     no need to specify - the 877a.inc file contains all the system registers
;trisc		equ		0x87
;portc		equ		0x07


			list		p=16f877A	; list directive to define processor
			#include	<p16f877A.inc>	; processor specific variable definitions


		__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF

;		__config 3f39   ??  this selects the RC osc, Watchdog Enabled and LVP on - which you do not want
;							use the full version as above so you can always see what bits you have set		


			cblock 0x20			; specify user registers
			d1,d2,d3			; delay work files
			endc



			org 0x0000
			goto	main

			#include delay.inc

main		call	sys_init
			call	led_on
			
led_on			
loop		movlw	0xff
			movwf	portc
			call	delay
			clrf	portc
			call	delay  	  ; also need a delay here otherwise the led will be on all the time
			goto	loop

sys_init	clrf	PORTC	; ensure portC is off.
			banksel	TRISC
			clrf	trisc
			banksel	0
			return


			end
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear wp100,

Big thanks for the reply and more advice . also I understand that individual bit configuration is better than the use of config hex word. If you do not take anger I would like to more clear out the bit configuration that you pointed out with my suggestion. please see the picture


CONFIG.JPG
Please advice
Thanks in advance
PA3040
 

Hi,

No, you are right, I read your hex config value incorrectly, sorry.

As you say is always better to list the bits in full, but if its a hex number then after building it, use MPlabs, Configure, Configuartion Bits to check the values.
 

Attachments

  • ScreenShot001.jpg
    ScreenShot001.jpg
    66.3 KB · Views: 133
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top