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 7th March 2007, 05:01 PM   (permalink)
Default First Program in assembly, And Programmer Inchworm.

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???
Ayne is offline   Reply With Quote
Old 7th March 2007, 05:22 PM   (permalink)
Default

wish mine was working
did you release it from reset?
what does your target circuit look like?

Last edited by williB; 7th March 2007 at 05:43 PM.
williB is offline   Reply With Quote
Old 7th March 2007, 05:30 PM   (permalink)
Default

I would check the configuration word.
eng1 is offline   Reply With Quote
Old 7th March 2007, 05:38 PM   (permalink)
Default

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
williB is offline   Reply With Quote
Old 7th March 2007, 06:01 PM   (permalink)
Default

I am using Firefly Z.........ZIF only to program PIC16F877A.
Ayne is offline   Reply With Quote
Old 7th March 2007, 06:21 PM   (permalink)
3v0
Default

What williB said.

Then use the Inchworm as an debugger(not programmer) to program, then try to step through you code.

If you do not know what I am talking about check out the Microchip
doc on MPLAB and debugging Esp chapter 5 on ICD.

http://ww1.microchip.com/downloads/en/devicedoc/51331B.pdf
3v0 is online now   Reply With Quote
Old 7th March 2007, 06:57 PM   (permalink)
Default

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???????????????????
Ayne is offline   Reply With Quote
Old 7th March 2007, 07:30 PM   (permalink)
Default

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 is offline   Reply With Quote
Old 8th March 2007, 02:15 AM   (permalink)
Default

Quote:
Originally Posted by Ayne
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
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 9th March 2007, 05:04 PM   (permalink)
Default

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
Quote:
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 is offline   Reply With Quote
Old 9th March 2007, 07:26 PM   (permalink)
Default

Ayne ,
if you just want to see it 'in memory '
click on the View tab , then click 'program memory'
williB is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
DSpic compiler and programmer jrz126 Micro Controllers 31 20th April 2008 10:03 PM
PIC Programmer using C burg General Electronics Chat 2 24th January 2007 07:26 AM
Getting started with PIC programming and building the Inchworm Hedos Micro Controllers 3 30th November 2006 02:44 AM
Using C or Assembly? rkim01 Micro Controllers 2 5th July 2006 02:06 PM
Newcomers, please read! (PIC regarded) Upd. 0xD Jay.slovak Micro Controllers 0 17th April 2005 01:04 PM



All times are GMT. The time now is 11:44 AM.


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