How add user defined header file to project

Status
Not open for further replies.

PA3040

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: 106
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


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
 
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



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
    66.3 KB · Views: 112
Reactions: PA3040

    PA3040

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

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…