+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 5
    Points: 51, Level: 1

    Join Date
    Mar 2017
    Posts
    8
    Helped
    0 / 0
    Points
    51
    Level
    1

    New to Microcontroller

    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

    •   AltAdvertisment

        
       

  2. #2
    Junior Member level 1
    Points: 502, Level: 4

    Join Date
    Mar 2016
    Posts
    16
    Helped
    6 / 6
    Points
    502
    Level
    4

    Re: New to Microcontroller

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

    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.



    •   AltAdvertisment

        
       

  3. #3
    Newbie level 5
    Points: 51, Level: 1

    Join Date
    Mar 2017
    Posts
    8
    Helped
    0 / 0
    Points
    51
    Level
    1

    Re: New to Microcontroller

    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 andre_teprom; 14th March 2017 at 22:56. Reason: added CODE tags



    •   AltAdvertisment

        
       

  4. #4
    Super Moderator
    Points: 28,508, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,474
    Helped
    1078 / 1078
    Points
    28,508
    Level
    41
    Blog Entries
    6

    Re: New to Microcontroller

    Pls i need help to program
    So far, no problem has been reported.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



--[[ ]]--