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.

Problem with PORTA in a MPLAB simulated code

Status
Not open for further replies.

smiles

Advanced Member level 4
Joined
Jul 27, 2007
Messages
110
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,096
Here is the code
Code:
	list		p=16f877a	; list directive to define processor
	#include	<p16f877a.inc>	; processor specific variable definitions
	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF
COUNT1      equ       08h                 ;First counter for our delay loops
;*******************************************************************
	org		0x0000
	goto 	Main
	org		0x0005		; processor reset vector
;****Set up the port**** 
Main
	banksel	TRISA
        movlw   01h            ;Set the Port A pins:
        movwf   TRISA          ;bit 1 to output, bit 0 to input.
	banksel	PORTA
	movlw   02h            ;Set up our w register with 02h 
Start1
	bsf  	PORTA,7        ;Set bit 7
        goto	Start1         ;go back to Start1  
	END
Compile it with MPLAB, it says successful like this
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Program Files\Microchip\MyProject\16F877ATMPo_O".
Clean: Deleted file "C:\Program Files\Microchip\MyProject\16F877ATMPO.lst".
Clean: Deleted file "C:\Program Files\Microchip\MyProject\Project.cof".
Clean Warning: File "C:\Program Files\Microchip\MyProject\Project.cod" doesn't exist.
Clean: Deleted file "C:\Program Files\Microchip\MyProject\Project.hex".
Clean Warning: File "C:\Program Files\Microchip\MyProject\Project.lst" doesn't exist.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F877A "16F877ATMPO.ASM" /l"16F877ATMPO.lst" /e"16F877ATMPO.err" /o"16F877ATMPo_O"
Message[302] C:\PROGRAM FILES\MICROCHIP\MYPROJECT\16F877ATMPO.ASM 14 : Register in operand not in bank 0. Ensure that bank bits are correct.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPLink.exe" "C:\Program Files\Microchip\MyProject\16f877a.lkr" "C:\Program Files\Microchip\MyProject\16F877ATMPo_O" /o"Project.cof" /M"Project.map" /W
MPLINK 4.12, Linker
Copyright (c) 2007 Microchip Technology Inc.
Errors : 0

MP2HEX 4.12, COFF to HEX File Converter
Copyright (c) 2007 Microchip Technology Inc.
Errors : 0

Loaded C:\Program Files\Microchip\MyProject\Project.cof.
BUILD SUCCEEDED: Sat Aug 04 11:17:23 2007

But when I use MPLAB SIMULATE, PORTA still 00000000 all time ?
Anyone know why ?
Thanks !!!
 

mpasm 16f877a.lkr

PORTA defaults to analog pin functions. You have to turn off both the comparators and also disable the analog mode on any pins you want to use for digital I/O
 

    smiles

    Points: 2
    Helpful Answer Positive Rating
mpasm not loading .inc files

Hi !!! Thanks for your help, I now make it run
Well, when I convert its .asm to .hex in order to load program for PIC16F877 in ISIS software of Proteus and simulate, I get this error, anyone help me a way

SIMULATION LOG
==============
Design: C:\Program Files\Labcenter Electronics\Proteus 6 Professional\BIN\Project.DSN
Doc. no.: <NONE>
Revision: <NONE>
Author: <NONE>
Created: 08/04/07
Modified: 08/04/07

Compiling source files...
Build completed OK.
Compiling netlist...
Linking netlist...
Partition analysis...

Simulating partition 1 [AC7103C0]...
Animation started sucessfully...
PROSPICE Release 6.9 SP2 (C) Labcenter Electronics 1993-2006.
SPICE Kernel Version 3f5. (C) Berkeley University ERL.

Reading netlist...
Reading SPICE models...
Building circuit...
Instantiating SPICE models...
[U1] PIC16 model release 6.9 SP0 simulating PIC16877 device.
[U1] Loaded 256 bytes of persistent EEPROM data.
[U1] Loading HEX file '..\..\..\..\Documents and Settings\Welcome\Desktop\abc.hex'.
FATAL: [U1] Program or EEPROM data has invalid address [2000] for this device

Real Time Simulation failed to start
Totaliters=0, Totalsteps=0, Goodsteps=0, Badsteps=0


Real Time Simulation FAILED.

Thanks !!!
 

Why it not run

Hi ! I got it right :)
I convert the .hex back to .asm use PicDisasm and I see the code is longer than I write itself before
they are:
;EPPROM Memory
ORG 0x2100
DE 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF ...
...
... (About 25 rows)
...
DE 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF ...
; Program Memory
; this part is exactly what I wrote
...
I guess and delete the part of .hex that contains EPPROM Memory, so .hex only contains my program
and everything is ok :)
I just understand that, if anyone find any more reasons please tell me !
Thanks !!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top