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.
 


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

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