PIC IO in assembly

  • Thread starter TylerH
  • Start date
  • Tags
    Assembly
  • #1
729
0
I need some help setting a pin high. I have tested all pins(incase I accidentally set the wrong one) with a multimeter, and none, other than Vdd and Vss, of course, were high. I also ran it in a simulator, and notice that the value at PORTA never changes, its always 0.

Is there something special I need to do to get it to start, or does it start as soon as it has current to Vdd and ground on Vss? Also, if it was fried, would a PICkit2 programmer, used with MPLAB, have an error message of some sort?

Code:
STATUS	equ 03h
PORTA	equ 05h
PORTB	equ 06h
TRISA	equ 85h
TRISB	equ 86h


start
	call	init
main
	movlw	02h
	xorwf	PORTA,01h
	
	movlw	0ffh
	call	delay
	call	delay
	goto	main


init
	bsf	STATUS,05h
	bcf	TRISA,01h
	bcf	STATUS,05h
	return


delay
	movwf	20h
wait
	decfsz	20h,01h
	goto	wait
	return
	
	end
 

Answers and Replies

  • #2
I think you may be wiggling the wrong bits in the STATUS register when swapping memory banks. I looked at the PCI16f81x data sheet (I use it a lot but in C, so don't remember ASM too good...) and it looks like bits 6&7 are the bank registers.

Also I believe setting a TRIS bit to 1 sets the pin to INPUT, not OUTPUT.

Check your spec sheet and see... or just try everything and anything in your simulator...
 
  • #3
Also, I don't see your clock configuration directive.
 
  • #4
Oh crap! feel like an idiot for not telling what PIC I'm using. It's a 16f628a.

schip666!: Mine uses <6:5> for normal bank selection, and 7 has something to do with indirect referencing and the bank it uses. You are correct that 0s in TRIS are for output, so I've corrected my code in that respect. I'd been forgetting to disable the comparators on PORTA, and after disabling them, the rights to PORTA show in the simulator's memory. Even though it seems to be working in the simulator, it doesn't do anything in my circuit.

Antiphon: I don't know the directives, I just use MPLAB's Configure->Configuration Bits menu option. What directives should I be using, or where could I learn them?

I've found a lot of references to "pulling up" pins to get it to reset. The only pins I have connected is +5V on Vdd and GND on Vss, should I have other things connected?

Also, here's my new code:
Code:
STATUS	equ 03h
PORTA	equ 05h
PORTB	equ 06h
CMCON	equ	1fh
TRISA	equ 85h
TRISB	equ 86h


start
	call	init
main
	call	switch
	movlw	0ffh
	call	delay
	btfsc	PORTA,01h
	call	delay
	goto	main


switch
	movlw	0fh
	xorwf	PORTA,01h
	return


delay
	movwf	20h
wait
	decfsz	20h,01h
	goto	wait
	return


init
	clrf	PORTA
	
	; disable comparators on RA<4:0>
	movlw	0x07
	movwf	CMCON
	
	bsf	STATUS,05h

	; set RA<4:0> to out
	movlw	00h
	movwf	TRISA
	
	bcf	STATUS,05h
	return
	
	end
 

Suggested for: PIC IO in assembly

Replies
16
Views
1K
Replies
10
Views
1K
Replies
1
Views
568
Replies
15
Views
3K
Replies
13
Views
2K
Replies
6
Views
613
Back
Top