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.

help :clocking a 4017 counter with pic16f84a

Status
Not open for further replies.

sukhoimg

Junior Member level 1
Joined
Aug 24, 2012
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,399
hello
i'am using a pic mcu to drive a 5x7 led matrix and a 4017 counter , but when i try to clock the 4017 i have an effect like a bouncing switch.
it's not stable and can't scan the rows when by one .
please help me.

here is the asm code that i"am using


LIST P=16F84A
#INCLUDE<P16F84A.INC>
CBLOCK 0X0C
TEMP:1
TEMP1:1
TEMP2:1
ENDC


ORG 0X00
GOTO INIT


ORG 0X05
INIT
CLRF PORTA
CLRF PORTB
BSF STATUS,5
CLRF TRISA
CLRF TRISB
BCF STATUS,5


START
BSF PORTA,2
CALL TEMPO
CALL TEMPO
CALL TEMPO
BCF PORTA,2

MOVLW B'01111111'
MOVWF PORTB
CLRF PORTB

BSF PORTA,2
CALL TEMPO
BCF PORTA,2



BSF PORTA,2
CALL TEMPO
BCF PORTA,2


BSF PORTA,2
CALL TEMPO
BCF PORTA,2



BSF PORTA,2
CALL TEMPO
BCF PORTA,2



BSF PORTA,3
CALL TEMPO
BCF PORTA,3




GOTO START

TEMPO
CLRF TEMP
CLRF TEMP1
BOUCLE
DECFSZ TEMP,f
GOTO BOUCLE
DECFSZ TEMP1,f
GOTO BOUCLE
RETURN



END
 
Last edited:

Hi,

If you are still stuck this might help.

You missed out an important detail and that is the frequency of the oscillator you are using.

For the answer I will assume a crystal of 4Mhz which means that 1 machine cycle, typically 1 instruction is 1Mhz or 1 us.

Now follow that code through as see what it does.


START
BSF PORTA,2 ; TURN ON A2
CALL TEMPO ; DELAY ABOUT 250MS X 3
CALL TEMPO
CALL TEMPO
BCF PORTA,2 ; TURN OFF A2

MOVLW B'01111111'
MOVWF PORTB ; TURN ON 7 BITS OF PORT B
CLRF PORTB ; TURN OFF PORT B 1us LATER !

BSF PORTA,2 ; TURN ON A2 ABOUT 4us AFTER YOU LAST TURNED IT OFF !
CALL TEMPO
BCF PORTA,2

; ; AGAIN JUST A 1 us GAP BETWEEN ON AND OFF

BSF PORTA,2
CALL TEMPO
BCF PORTA,2


BSF PORTA,2
CALL TEMPO
BCF PORTA,2



BSF PORTA,2
CALL TEMPO
BCF PORTA,2



BSF PORTA,3 ; NOW YOU TURN ON A3 BUT ONLY AFTER A2 HAS SWITCHED ON AND OFF 4 TIMES
CALL TEMPO
BCF PORTA,3

All those 1us gaps will be read by the 4017 but because its so fast you only see them on your display as jitter or garbage

Also ensure the Watchdog is turned off by using this line of code.
Code:
	LIST P=16F84A
	#INCLUDE<P16F84A.INC>

	__CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
 

hello
yes i'am using 4MHZ osc, but i did not understand where the problem is hard or soft ?
i wrote a new code :


;**********************************************************************
; PROJET ECRIRE LA LETRRE A SUR UNE MATRICE LED 5X7 *
;*********************************************************************
LIST P=16F84A
#INCLUDE<P16F84A.INC>
CBLOCK 0X0C
TEMP:1
TEMP1:1
TEMP2:1
ENDC


ORG 0X00
GOTO INIT


ORG 0X05
INIT
CLRF PORTA
CLRF PORTB
BSF STATUS,5
CLRF TRISA
CLRF TRISB
BCF STATUS,5


START


MOVLW B'01111111' ;CHARGER LA PRMIERE COLONNE DE LA MATRICE
MOVWF PORTB


BSF PORTA,0
CALL TEMPO
BCF PORTA,0


MOVLW B'00000101' ; CHRGER LA DEXIEME COLONNE DE LA MATRICE
MOVWF PORTB

BSF PORTA,0
CALL TEMPO
BCF PORTA,0


BSF PORTA,0
CALL TEMPO
BCF PORTA,0



BSF PORTA,0
CALL TEMPO
BCF PORTA,0





MOVLW B'01111111' ;CHARGER LA DERNIERE COLONNE DE LA MATRICE
MOVWF PORTB


BSF PORTA,0
CALL TEMPO
BCF PORTA,0

BSF PORTA,1 ; RESET DU 4017
CALL TEMPO
BCF PORTA,1


GOTO START

TEMPO
CLRF TEMP
MOVLW 0X04
MOVWF TEMP1
BOUCLE
DECFSZ TEMP,f
GOTO BOUCLE
DECFSZ TEMP1,f
GOTO BOUCLE
RETURN



END
 

Attachments

  • schema.bmp
    88.8 KB · Views: 55

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top