Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

New to Microcontroller

Status
Not open for further replies.

Jhamiu

Newbie level 5
Joined
Mar 10, 2017
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
58
Pls i need help to program pic16f84a to count from 0 to 48 when push button is pressed and go back again when it reaches 48.
Push button is connected to Ra1
The driving resistors are connected to Ra2 and Ra3
The input port of the multiplexed 7segment display are connected to rb1 to rb7
The two common anode 7segment display are multiplexed drived through a transistor.
Se image for the circuit diagram
 

Nobody can help you with just scarce informations and a diagram at the size of a postage stamp :roll:.

Show what you have, what you tried, what you expected and what you got instead.

It won't work if you are not willing to invest at least a little of your own sweat.
 

This code from 0 to 99

Code:
	 __CONFIG 1BH
 
	BSF 03h,5
	movlw b'11100'
	movwf 85h
	movlw b'00000001'
	movwf 86h
	BCF 03h,5
	goto main

PC	 EQU 02H
STATUS   EQU 03H
PORTA	 EQU 05H
PORTB	 EQU 06H
TRISA	 EQU 85H
TRISB	 EQU 86H

DIGIT1	 EQU 10H
DIGIT2	 EQU 11H

		
TABLE 	 ADDWF	PC,1
	 RETLW 	b'01111110'
	 RETLW  b'00011000'	;digit1
	 RETLW  b'10110110'	;digit2
	 RETLW  b'10111100'	;digit3
	 RETLW  b'11011000'	;digit4
	 RETLW  b'11101100'	;digit5
	 RETLW  b'11101110'	;digit6
	 RETLW  b'00111000'	;digit7
	 RETLW  b'11111110'	;digit8
	 RETLW  b'11111100'	;digit9
	 
main	 CLRF DIGIT1
	 CLRF DIGIT2

;***********display the digit1***************

LOOP	 BCF PORTA,0	;disable digit2
	 MOVF DIGIT1,0
	 CALL TABLE
	 MOVWF PORTB
	 BSF PORTA,1	;enable digit1

	 CALL Delay	;Small delay to display digit1


;***********display the digit2***************


	 BCF PORTA,1	;disable digit1
	 MOVF DIGIT2,0
	 CALL TABLE
	 MOVWF PORTB
	 BSF PORTA,0	;enable digit2

	 CALL Delay	;Small delay to display digit2


;**********check the button is pressed*******


PRESS	 BTFSS PORTB,0	;Button Pressed
	 GOTO COUNTUP	;If yes Countup
	 GOTO LOOP	;Back to Loop


;*********update digit1 & digit2************


COUNTUP  INCF DIGIT1,1	;increase digit1
	 MOVLW 0AH	;load with ten
	 XORWF DIGIT1,0	;compare
	 BTFSS STATUS,2
	 GOTO LOOP
	 CLRF DIGIT1
	 INCF DIGIT2,1	;increase digit2
	 MOVLW 0AH	;load with ten
	 XORWF DIGIT2,0	;compare
	 BTFSC STATUS,2
	 CLRF DIGIT1
	 GOTO LOOP

Delay  	 DECFSZ 1Bh,1      ;Delay for viewing the display
         GOTO Delay
         RETURN
	


	 end
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top