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.

Software to Simulate PIC Microcontroller

Status
Not open for further replies.
btfsc PORTA,0 ;check button pressed.
goto on
bsf PORTB,0 ;turn on led.
call delay5 ;call 5 second delay
bcf PORTB,0 ;turn off led.
Call delay5 ;Missing form your code
goto on ;repeat
end



If you using the code from the book, you have a line of code missing, this is a second delay call after the led is switched off.
 

Ya may this can be the problem. As a beginner, i took this sample code from a Dr W. Smith's book ( all the code in his book is tested and verified). Now i am trying to debug it to find out thepossible error.
In programming using LP crystal 32768 hz. PicF84 timing is 1/4 of the crystal i.e. 32768/4 =8192hz. using presacler with value b '00000111' ( to divide it with 256) to have 32 cycle is second. Therefore to have 5 seconds 5*32 = 160 seconds.
problem occurs while simulating the code. That is why i attached actual asm and simulator file to specify where is the problem.

Thanks.
Regards,

Hi,
Are you still having problems? I ran with this code:
Code:
ZEROBIT equ 2 			;ZEROBIT is bit 2.
COUNT equ 0ch 			;user ram location.

;************************************************* *********
list p=16f84a 			;we are using the 16f84
#include <p16f84a.inc>

org 0000H 				;0x00 is the start address.
goto start 				;goto start!

;************************************************* *********
;configuration bits
__config h'3ff0' ;selects lp oscillator, wdt off, put on,
;code protection disabled.
;************************************************* ****

;subroutine section.

								;5 second delay.
delay5:
	clrf TMR0 						;start tmr0.
loopA:
	movf 	TMR0,w 					;read tmr0
	sublw 	160 						;time - 160
	btfss 	STATUS,ZEROBIT			 ;chec	k time-w¼0
	goto 	loopA						 ;time is not¼160.
	retlw 	0 						;time is 160, return.

;************************************************* *********
;configuration section.

start:
	bsf STATUS,5 				;turn to bank1
	movlw b'00011111' 			;5 bits of PORTA are i/ps.
	movwf TRISA
;movlw b'00000000'
;movwf TRISB				 ;PORTB is output
	CLRF TRISB 					;is enough
	movlw b'00000111'
	movwf OPTION_REG				 ;prescaler is /256
	bcf STATUS,5 				;return to bank0
	clrf PORTA 					;clears PORTA
	clrf PORTB 					;clears PORTB
	clrf COUNT
;************************************************* ********

;program starts now.

on:
	btfsc 	PORTA,0 			;check button pressed.
	goto 	on
	bsf 	PORTB,0 			;turn on led.
	call 	delay5				 ;call 5 second delay
	bcf 	PORTB,0 			;turn off led.
	call 	delay5
	goto 	on 				;repeat
end

And it's fine. What exactly is the problem?

Hope this helps.
Tahmid.
 

Dear cadvis,
You may be having in correct working because of the absence of the delay5 routine. Just check the code once more after including it in the code.
Regards,
Jerin. ;-)
 

Hi,

Sorry to distrub you again and again. I am facing problem while simulating the code either
using 'Real Pic Simulator' or 'PIc Simulator IDC'. LED does not follow 5 sec delay to remain on and off.

Using MPLAB v 8.10 as code editor to generate 'hex file' then open that 'Hex File' in real PIC Simaulator'

. Seetings are:
processor: 16F84
Simulation Speed: 4,000,000
Actual Speed: 4,000,000

**broken link removed**


I have upload the files with code you provided to me. Thank you very much for your time and cooperation.

What software are you using to simulate this asm code?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top