• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.
STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT equ 21h
COUNT2 equ 22h

bsf STATUS, 5
movlw b'00001
movwf PORTA
bcf STATUS, 5

start bsf PORTA, 1
call delay
bcf PORTA, 1
call delay
btfss PORTA,0
call stop
goto start

delay decfsz COUNT, 1
goto delay
decfsz COUNT2, 1
goto delay
return

stop goto stop

end
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:

bananasiong

New Member
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
 

colin mac

New Member
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

bananasiong

New Member
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

Last edited:

bananasiong

New Member
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.
 

colin mac

New Member
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.

Latest threads

EE World Online Articles

Loading
Top