Set PIC IO Pin High - Assembly Help

  • Thread starter TylerH
  • Start date
  • Tags
    Assembly
In summary, the conversation is about troubleshooting a problem with setting a pin high on a PIC 16f628a. The person has tested all pins and has determined that only Vdd and Vss are high. They have also run a simulation and noticed that the value at PORTA is always 0. They are wondering if there is something special they need to do to get the pin to start, or if it starts as soon as there is current to Vdd and ground on Vss. They also ask if a PICkit2 programmer would have an error message if the PIC was fried. The conversation also touches on using the wrong bits in the STATUS register and setting pins to input instead of output. The person also asks about clock configuration and
  • #1
TylerH
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
 
Technology news on Phys.org
  • #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 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
 
  • #5


It seems like you are having trouble setting a specific pin high on your PIC microcontroller. First, make sure that you have tested all the pins and have the correct pin number for the one you want to set high. It is also important to double check your code and make sure there are no errors or typos.

In terms of getting the pin to start, it should start as soon as there is current to Vdd and ground on Vss. If you are unsure if the microcontroller is working properly, you can try using a PICkit2 programmer with MPLAB to see if there are any error messages.

Looking at your code, it seems like you are setting the TRISA register to 0, which means that all the pins on PORTA will be set as outputs. If you want to set a specific pin high, you will need to set that pin as an output and then use the XORWF command to toggle the value of that pin. I would suggest checking the datasheet for your specific microcontroller to make sure you are using the correct commands and registers.

I hope this helps and good luck with your project!
 

Related to Set PIC IO Pin High - Assembly Help

1. What is "Set PIC IO Pin High" in assembly language?

"Set PIC IO Pin High" is an assembly language instruction that is used to set a specific input/output (IO) pin on a PIC microcontroller to a high voltage level. This instruction allows the microcontroller to control and communicate with external devices by toggling the voltage on the IO pin.

2. How is "Set PIC IO Pin High" different from other instructions?

"Set PIC IO Pin High" is different from other instructions because it specifically targets a single IO pin on a PIC microcontroller. Other instructions may control multiple pins or have different functions, but "Set PIC IO Pin High" is solely used for setting a specific pin to a high voltage level.

3. Why would I need to use "Set PIC IO Pin High" in assembly language?

"Set PIC IO Pin High" is commonly used in assembly language to control external devices connected to the PIC microcontroller. By setting a specific pin to a high voltage level, the microcontroller can signal to the external device to perform a specific action, such as turning on an LED or reading a sensor.

4. How do I use "Set PIC IO Pin High" in my assembly language program?

To use "Set PIC IO Pin High" in your assembly language program, you will need to first identify the specific IO pin you want to set to a high voltage level. Then, you will need to use the corresponding instruction for your specific PIC microcontroller model. Consult your microcontroller's datasheet or programming guide for the exact syntax and usage of the instruction.

5. Are there any precautions I should take when using "Set PIC IO Pin High" in assembly language?

Yes, there are a few precautions to keep in mind when using "Set PIC IO Pin High" in assembly language. First, make sure you are targeting the correct IO pin and that it is not already set to a high voltage level. Additionally, be aware of the voltage and current limitations of your microcontroller and the external device connected to the IO pin. Improper usage could potentially damage your components. Finally, it is important to properly configure and initialize your microcontroller before using "Set PIC IO Pin High" to avoid unexpected behavior.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Electrical Engineering
Replies
9
Views
2K
  • Electrical Engineering
Replies
10
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
7K
  • General Engineering
Replies
2
Views
3K
  • Electrical Engineering
Replies
2
Views
2K
Back
Top