Continue to Site

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.

  • 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.

16f628a RA4 problem

Status
Not open for further replies.

birdman0_o

Active Member
Hey guys, I've been playing around tonight and I've run into a problem with Bit 4 of the A register. It is set as output and I am turning it on high, but it is not turning it on. I can't imagine TOCKI being set, which is what is shared with that pin. I've never had this problem before!

Here is my code...Thanks ahead of time :)


Code:
;*************************************
; Author  : Mike Baird
; Program : Template
; Date    : 
;*************************************
; Table
;		    					    (f) Left Top = bit5
;		    __   (a) Top    = bit0 	(b) Righ Top = bit1   
;		   |__|  (g) Middle = bit6  (e) Left Bot = bit4
;		   |__|  (d) Bottom = bit3	(c) Righ Bot = bit2
;
;0 = b'00111111'
;1 = b'00000110'
;2 = b'01011011'
;3 = b'01001111'
;4 = b'01011010'  <-
;5 = b'01110011'  <-
;6 = b'01110111'  <-			
;7 = b'00101010'  <-
;8 = b'01111111'  <-
;9 = b'01111010'  <-
;*************************************

	List	P=16F628
	#include	"P16F628.INC"
	__config	_PWRTE_ON  & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_ON & _LVP_OFF & _CP_OFF & _MCLRE_OFF

;*** Cblock ***

	CBLOCK	0x20		 
	d1					; 
	d2					;
	Number1				;
	Number2				;
	Number3				;
	Number4				; 
	ENDC

;*** Defines ***

#Define Bits 	PORTA,0
#Define Clock	PORTA,7
#Define Latch	PORTA,6

;*** Macro ***

HC595 MACRO Var,Var1

	Local Loop		; Local Label
	MOVLW .8		; Transfer 8 bits
  	MOVWF Var1		; Initializing counter

Loop	
	RLF Var,f	; Rotate "Var" one place to the left
	BTFSS STATUS,C	; Is carry 1?
	BCF Bits		; If not set data line to 0
	BTFSC STATUS,C	; Is carry 0?
	BSF Bits		; If not set data line to 1

	BSF Clock		; Generate one clock
	BCF Clock		;

	DECFSZ Var1,f	; Has 8 bits been sent?
	GOTO Loop		; If not, repeat

	BSF Latch		; If all 8 bits have been sent, set latch
	BCF Latch

	ENDM

;*** START OF RAM ***
	ORG	0x000			; Start of program vector
	GOTO	Start		;
	ORG	0x004			; Interrupt vector
;	Goto ISR
	

Start
	MOVLW	0x07		; Turn comparators off and enable pins for I/O
	MOVWF	CMCON		; ^
	CLRF	PORTA		; PortA all low
	CLRF	PORTB		; PortB all low

	
	BSF	STATUS,RP0		; Bank 1
	MOVLW b'00100000'	;
	MOVWF	TRISA		; PortA all output except MCLR
	CLRF	TRISB		; PortB all output
	BCF	STATUS,RP0		; Bank 0

Main:
	BCF PORTA,4
	BSF PORTA,1
	MOVLW b'00111111'
	MOVWF Number1
	HC595 Number1,Number2
	Call Delay

	BCF PORTA,1
	BSF PORTA,2
	MOVLW b'00000110'
	MOVWF Number1
	HC595 Number1,Number2
	Call Delay

	BCF PORTA,2
	BSF PORTA,3
	MOVLW b'01011011'
	MOVWF Number1
	HC595 Number1,Number2
	Call Delay

	BCF PORTA,3
	BSF PORTA,4
	MOVLW b'01001111'
	MOVWF Number1
	HC595 Number1,Number2
	Call Delay

	GOTO Main






; *** Delay ***
Delay	
	MOVLW	d'255'
	MOVWF	d1
	MOVLW	d'255'
	MOVWF	d2
D2	
	DECFSZ	d1,F
	GOTO	D2
	DECFSZ	d2,F
	GOTO	D2
	RETURN

;********************

	END

; That's all folks!
 
Hey guys, I've been playing around tonight and I've run into a problem with Bit 4 of the A register. It is set as output and I am turning it on high, but it is not turning it on.
RA4 is an open drain output. That means it can be used to sink current, but not to source current.

Another thing to remember is that when configured as an input, RA4 is a Schmitt Trigger input.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top