Set PIC IO Pin High - Assembly Help

  • Thread starter Thread starter TylerH
  • Start date Start date
  • Tags Tags
    Assembly
Click For Summary
The discussion centers around troubleshooting issues with setting a pin high on a PIC16F628A microcontroller. The user has confirmed that only Vdd and Vss are receiving power, and PORTA remains at 0 despite testing various configurations. They seek clarification on whether the microcontroller starts functioning immediately upon powering or requires additional setup. Key points include the need to correctly configure the TRIS register, as setting a TRIS bit to 1 designates a pin as input, while 0 sets it as output. The user also mentions disabling comparators on PORTA, which is crucial for proper functionality. There is a discussion about using MPLAB for configuration directives, with a suggestion to explore the Configuration Bits menu for necessary settings. Additionally, the importance of ensuring proper connections, including potential pull-up resistors, is highlighted. The user is encouraged to test their code in the simulator and verify hardware connections to resolve the issue.
TylerH
Messages
729
Reaction score
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
 
Technology news on Phys.org
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...
 
Also, I don't see your clock configuration directive.
 
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 86hstart
	call	init
main
	call	switch
	movlw	0ffh
	call	delay
	btfsc	PORTA,01h
	call	delay
	goto	mainswitch
	movlw	0fh
	xorwf	PORTA,01h
	returndelay
	movwf	20h
wait
	decfsz	20h,01h
	goto	wait
	returninit
	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
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K