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.

First Program in assembly, And Programmer Inchworm.

Status
Not open for further replies.

Ayne

New Member
I am using Inchworm to program My targeted Microcontroller, my targeted microcontroller is also PIC16F877A.

I write this program in Assembly

Code:
;**********Declaration & Microcontroller configuration**************
		Processor	16F877A
		#include	"P16F877A.INC"

		__config	0x3F3A

;*******************Declaration of Variable*************************
		cblock		0x20
		CounterA
		CounterB
		CounterC
		endc

;******************Program memory structure*************************
		org		0x0000
		goto	main

;************************Main Program********************************
main
		movlw	b'00000000'
		movwf	TRISC

Program
		movlw	b'00000000'
		movwf	PORTC
		call	Delay

		movlw	b'11111111'
		movwf	PORTC
		call	Delay

		goto 	Program		;Endless loop

Delay
;PIC Time Delay = 0.3130012 s with Osc = 20.000000 MHz
	movlw	D'8'
	movwf	CounterC
	movlw	D'248'
	movwf	CounterB
	movlw	D'106'
	movwf	CounterA
loop	decfsz	CounterA,1
	goto	loop
	decfsz	CounterB,1
	goto	loop
	decfsz	CounterC,1
	goto	loop
	return

	END

Then i build
Code:
Clean: Deleting intermediary and output files.
Clean: Deleted file "LED.err".
Clean: Deleted file "E:\Projects\LedTest\LED.cod".
Clean: Deleted file "E:\Projects\LedTest\LED.hex".
Clean: Deleted file "LED.lst".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F877A "LED.asm" /l"LED.lst" /e"LED.err"
Message[302] E:\PROJECTS\LEDTEST\LED.ASM 21 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Loaded E:\Projects\LedTest\LED.COD.
BUILD SUCCEEDED: Wed Mar 07 22:58:48 2007

Feed program in PIC using inchworm. the result is
Code:
MPLAB ICD 2 Ready
Erasing Target Device...
...Erase Succeeded
MPLAB ICD 2 Ready
Blank Checking...
...Program Memory
.. Config Memory
...EEPROM
...User ID Memory
...Blank Check Passed
MPLAB ICD 2 Ready
Programming Target...
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0xB7)
Verifying...
...Program Memory
...Verify Succeeded
Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
...Verify Succeeded
...Programming succeeded
07-Mar-2007, 22:51:58

MPLAB ICD 2 Ready

But LEDs are not blinking on PORTC....
Where is the mistake???
 
wish mine was working
did you release it from reset?
what does your target circuit look like?
 
Last edited:
To run a PIC
you need to power the chip
apply 5V to mclr to keep it out of reset
it must oscillate (with a clock chip or a crystal)
and the LED circuit must be hooked up correctly.
if all this is correct , maybe it is blinking too fast to see
 
spouse i have a hex file compiled from another compiler(Mikrobasic) & want to feed this hex file into my targeted controller(PIC16F877A)..... how can i do this using inchworm???????????????????
 
Thanks to the Lord Allah........
Problem solved...

There is a little mistake in program, i didn't select proper Banks for Registers.
Below is the correct program,
Code:
;**********Declaration & Microcontroller configuration**************
		Processor	16F877A
		#include	"P16F877A.INC"

		__config	0x3F3A

;*******************Declaration of Variable*************************
		cblock		0x20
		CounterA
		CounterB
		CounterC
		endc

;******************Program memory structure*************************
		org		0x0000
		goto	main

;************************Main Program********************************
main
		banksel	TRISD
		movlw	b'00000000'
		movwf	TRISD

Program
		banksel PORTD
		movlw	b'10101010'
		movwf	PORTD
		call	Delay

		movlw	b'01010101'
		movwf	PORTD
		call	Delay

		goto 	Program		;Endless loop

Delay
;PIC Time Delay = 0.3130012 s with Osc = 20.000000 MHz
	movlw	D'8'
	movwf	CounterC
	movlw	D'248'
	movwf	CounterB
	movlw	D'106'
	movwf	CounterA
loop	decfsz	CounterA,1
	goto	loop
	decfsz	CounterB,1
	goto	loop
	decfsz	CounterC,1
	goto	loop
	return

	END
 
Ayne said:
spouse i have a hex file compiled from another compiler(Mikrobasic) & want to feed this hex file into my targeted controller(PIC16F877A)..... how can i do this using inchworm???????????????????

Easy, from MPLAB
File / Import "filename.hex"

That's it, PICBASIC Pro can be integrated into MPLAB
 
I have a HEX file named LEDS.HEX in my computer want to feed this file into PIC16F877A using inchworm.

1. I open MPLAB
2. I press File>Import, then i select my desired HEX file
3. OUTPUT windows is showing in Build tab
Loaded C:\Documents and Settings\Administrator\My Documents\LEDS.hex.
4. The problem is how can i see the loaded hex file into MPLAB???
 
Ayne ,
if you just want to see it 'in memory '
click on the View tab , then click 'program memory'
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top