Proteus PIC simulation

Status
Not open for further replies.

colin mac

New Member
Just started learning asm for PIC16F876A and I can't read an input in Isis with
btfsc or btfss instructions.
RA1 is flashing an led but I want it to stop when RA0 goes low. It doesn't.
Anyone know what might be wrong?
 
Last edited:
Hi,
How's the connection of the schematic? Active low input or active high? To avoid confusion, please use
Code:
#include <p16F876A.inc>
bsf STATUS, RP0
movlw b'00001
movwf TRISA
bcf STATUS, RP0
instead of
Code:
bsf STATUS, 5
movlw b'00001
movwf PORTA
bcf STATUS, 5
 
RA1 is flashing an led but I want it to stop when RA0 goes low. It doesn't.
Anyone know what might be wrong?

Code:
Flash	bsf	PORTA,1		;Blink routine
	call	Delay		;//
	bcf	PORTA,1		;//
	call	Delay		;//

Che_SW	btfsc	PORTA,0		;Is Switch pressed?
	goto	Flash		;no,then loop the blink
	
Stop	goto	Stop		;yes,then stop the blink
 
There wasn't anything wrong with my code? this looks like the same program written in a different way.

Code:
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT equ 21h
COUNT2 equ 22h

#include <p16F876A.inc>

bsf STATUS, RP0
movlw b'00001
movwf TRISA
bcf STATUS, RP0

Flash	bsf PORTA, 1	
    	call Delay	
	bcf PORTA, 1	
        call Delay		

Che_SW btfsc PORTA,0		
	goto Flash		
	
Stop goto Stop

Delay decfsz COUNT, 1
      goto Delay
      decfsz COUNT2, 1
      goto Delay
      return
end
Anyway, Proteus is acting up on me with that code too. RA1 doesn't toggle when RA0 is both high and low now.

Could you tell me how to select the RC oscillator so I can try it in real life please?
 

Attachments

  • pic.PNG
    4.4 KB · Views: 251
Hi,
Check the configuration setting from the template provided by Microchip and refer to the inc file.

*EDIT:
Once you have
Code:
#include <p16F876A.inc>
you don't need these anymore
Code:
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
because they are predefined in the inc file.
 

Attachments

  • 876A.zip
    3.9 KB · Views: 186
Last edited:
Hi,
Other need to be configured too. Check the datasheet under Special Features of the CPU, bit by bit. The code protection for the program memory and EEPROM depends on you whether or not to set them. Usually high voltage programming (bit 7) is used, depends on your programmer. BOR and PWRTEN are good to be enabled. WDT is disabled.
It takes some time to understand, but for the first time, just copy other's example and test.
 
Ok, thanks you. I'll look into it.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…