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.

Shifting(74LS164) is not working!!

Status
Not open for further replies.
Here you can use this if you want to see how it works better
Code:
    LIST	p=16F877a		;tell assembler what chip we are using
	include "P16f877a.inc"		;include the defaults for the chip
	ERRORLEVEL	0,	-302	;suppress bank selection messages
	__config 0x399A			;sets the configuration settings (oscillator type etc.)




		cblock	0x20			;start of general purpose registers
		d1
		d2
		
		Tx
        CountSPI
        endc
		#define data PORTC,1
		#define clock PORTC,0
HC164   macro  var,var1
		Local   SendLoop
         movlw   .8     ;8 bits to send out
         movwf   var1 ; counter to count out the bits
SendLoop:
         rlf         var,f          ;rotate var left one place
         btfss    STATUS,C  ; is carry a 1
         bcf        data         ; if not set data to 0
         btfsc    STATUS,C   ; is carry a 0
         bsf        data         ;if not set data to 1
         
         bsf       clock          ; generate a clock 
         nop                       ;two nop for clock delay
         nop
         bcf        clock
         decfsz  var1,f        ;has eight bit been sent 
         goto SendLoop ; if not go back and keep loading till done
		endm
		org	0x0000
	;	include "HC164.INC"
Start		
		movlw	0x07
		movwf	CMCON			;turn comparators off (make it like a 16F84)	
		banksel TRISC
		movlw  B'00000000'
		movwf TRISC
		banksel TRISD
		movlw  B'00000000'
		movwf TRISD
		banksel PORTC
		clrf PORTC
		banksel PORTD
		clrf PORTD
main 	
                call send0
		call Delay
		call send1
		call Delay
		call send2
		call Delay
		call send3
		call Delay
		call send4
		call Delay
		call send5
		call Delay
		call send6
		call Delay
		goto main		
			
		
send0	
		movlw b'00111111'
		movwf PORTD
                movlw   b'00000111'          ;fulls the buffer
               movwf   Tx              ; Tx <- '110010011'
               HC164   Tx,CountSPI  ;lets the macro send the data
               return
send1
   		movlw b'01011111'
		movwf PORTD
               movlw   b'10111000'          ;fulls the buffer
                movwf   Tx              ; Tx <- '110010011'
               HC164   Tx,CountSPI  ;lets the macro send the data
		return
send2
   		movlw b'00101111'
		movwf PORTD
               movlw   b'01110001'          ;fulls the buffer
               movwf   Tx              ; Tx <- '110010011'
               HC164   Tx,CountSPI  ;lets the macro send the data
		return
send3
   		movlw b'01110111'
		movwf PORTD
                movlw   b'11100001'          ;fulls the buffer
                movwf   Tx              ; Tx <- '110010011'
                HC164   Tx,CountSPI  ;lets the macro send the data
		return
send4
   		movlw b'01111011'
		movwf PORTD
                movlw   b'11000011'          ;fulls the buffer
                movwf   Tx              ; Tx <- '110010011'
                HC164   Tx,CountSPI  ;lets the macro send the data
		return
send5
   		movlw b'01111101'
		movwf PORTD
                movlw   b'10000111'          ;fulls the buffer
               movwf   Tx              ; Tx <- '110010011'
                HC164   Tx,CountSPI  ;lets the macro send the data
		return
send6
   		movlw b'01111110'
		movwf PORTD
               movlw   b'00001111'          ;fulls the buffer
                movwf   Tx              ; Tx <- '110010011'
               HC164   Tx,CountSPI  ;lets the macro send the data
		return
Delay				;49993 cycles
		movlw	0x0E
		movwf	d1
		movlw	0x28
		movwf	d2
Delay_0
		decfsz	d1, f
		goto	$+2
		decfsz	d2, f
		goto	Delay_0

			;3 cycles
		goto	$+1
		nop

			;4 cycles (including call)
		return
  end
I didn't change all of these Tx <- '110010011' it is the binary (movlw b'00001111' ;fulls the buffer)
 
Last edited:
hi be80be,

Thanks sir , it's amazing! btw i found out the problem why for so long my microcontroller is not working .. it's because my /MCLR i put it unconnected .. i will try your code =)..
 
I'll tell you one better then that I worked on some letters for about 2 hours programed
my pic and it didn't change. I was changing the code i did for you lol and loading my old hex the new hex was in the sub folder
 
hi be80be ,

:D i have been working only on that led matrix for 3 weeks and my time is getting shorter .. luckily turn out got people helping me out as like sir you did give me a hand..

actually it's quite hard for me to get into assembly programming , because MPLAB not as good as C# or C++ because they can just prove that your code is just following the rules wherelse for high-level compiler from microsoft they can detect everything that in the code even a single bit error ..

well , i found that C# and C++ is easier than assembly , but sadly i only know these language that only use for database but not User interface :p.
 
I've done that too be8, you kick yourself for it, but it's sooo nice to know you've got it solved.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top