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.

105 leds with a pic12f683

Status
Not open for further replies.

be80be

Well-Known Member
Well I got the thing to scroll the leds now I need to add a way to change my patten here a look [embed]http://www.youtube.com/v/ShmWUE1sRBM&hl=en&fs=1[/embed] and here the code
Code:
;******************************************************************


 #include <p12f683.inc>			; Include pre-defined port/reg labels
	errorlevel  -302          ; suppress message 302 from list file
 __CONFIG   _FCMEN_ON & _IESO_OFF & _CP_OFF & _CPD_OFF & _BOD_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT 									
				; for your specific device.




;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Defines
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	cblock 0x20
	TX 
	TX1          					; Define variable at address 0x20 of
	CountSPI 
	CountSPI1
	d1
	d2
	endc							; General Purpose Register (GPR) memory.
	
	#define  Data GPIO,0
	#define	 Clock GPIO,1
	#define	 Latch GPIO,2
	#define	 Clock1   GPIO,4
	#define	 Data1   GPIO,5



;******************************************************************
; PROGRAM CODE
;******************************************************************

	org 0x0000						; Processor Reset Vector (code starts here on reset)

	goto Main					; On power-up, begin at label "Main:"

	org 0x0004						; Interrupt Vector (code jumps here on interrupt)
	goto Main							; Applies to midrange parts!

	include "hc595.inc"
	include "hc164.inc"
	; Place code to determine source of interrupt (check flags)
	; and to handle interrupt accordingly here  (your action)
	; as your Interrupt Service Routine (ISR) code.
	

Main:

	movlw 	07h	 ;set GP<2:0> to
	movfw   CMCON0	 ;digital I/O
	banksel ANSEL;
	clrf	ANSEL;digtal I/O
	banksel TRISIO
	movlw	b'001000'  ;set inputs and outputs
	movwf 	TRISIO ;moves it to TRIS 				; Initialize any ports as inputs/outputs, etc. here
	banksel GPIO
	clrf    GPIO
Loop:
Send
	call	col0
	call 	Roll1
	call	col1
	call	Roll2
	call	col2
	call	Roll3
	call	col3
	goto	Send1
Send1
	call	col4
	call 	Roll3
	call	col5
	call	Roll2
	call	col6
	call	Roll1
	call	col7
	goto	Send2
Send2
	call	col0
	call 	Roll1
	call	col1
	call	Roll2
	call	col2
	call	Roll3
	call	col3
	goto	Send3
Send3
	call	col4
	call 	Roll3
	call	col5
	call	Roll2
	call	col6
	call	Roll1
	call	col7
	goto    Send4
Send4
	call	col0
	call 	Roll1
	call	col1
	call	Roll2
	call	col2
	call	Roll3
	call	col3
	goto    Send5
Send5
	call	col4
	call 	Roll3
	call	col5
	call	Roll2
	call	col6
	call	Roll1
	call	col7
	goto	Send6
Send6
	call	col0
	call 	Roll1
	call	col1
	call	Roll2
	call	col2
	call	Roll3
	call	col3
	goto	Send7
Send7
	call	col4
	call 	Roll3
	call	col5
	call	Roll2
	call	col6
	call	Roll1
	call	col7								; Place Application Code Here.
	goto 	Send
col0
	movlw 	0x1			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col1
	movlw 	0x2			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col2
	movlw 	0x4			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col3
	movlw 	0x8			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col4
	movlw 	0x10			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col5
	movlw 	0x20			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return	
col6
	movlw 	0x40			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
col7
	movlw 	0x80			;fill tx buffer
	movwf	TX
	HC595   TX,CountSPI
	call    delay
	return
Roll1:
	movlw 	0x8			;fill tx buffer
	movwf	TX1
	HC164   TX1,CountSPI1
	return
Roll2:
	movlw 	0x1C			;fill tx buffer
	movwf	TX1
	HC164   TX1,CountSPI1
	return
Roll3:
	movlw 	0x3E			;fill tx buffer
	movwf	TX1
	HC164   TX1,CountSPI1
	return
Roll4:
	movlw 	0xff			;fill tx buffer
	movwf	TX1
	HC164   TX1,CountSPI1
	return
delay:
		;29998 cycles
	movlw	0x6F
	movwf	d1
	movlw	0x18
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0

			;2 cycles
	goto	$+1


	return

	end							; Program code stops here
and the two macro to shif out the data
Code:
HC595 macro Var,Var1
	
	Local 	Loop		;label
	movlw	.8		;eight bits to send
	movwf	Var1		
Loop
	rlf		Var,f		;rotate Var to the left

	btfss 	STATUS,C	;carry = 1 ?
	bcf		Data		;if not set line to 0
	btfsc	STATUS,C	;is carry = 0 ?
	bsf		Data		;if not set, set data line to 1

	bsf		Clock		; generate 1 clock
	nop
	bcf		Clock
	
	decfsz	Var1,f		;bits been sent ?
	goto	Loop		;if not repeat
	
	bsf     Latch
	nop
	bcf		Latch

	endm
Code:
HC164 macro Var0,Var2
	
	Local 	Loop		;label
	movlw	.8		;eight bits to send
	movwf	Var2		
Loop
	rlf		Var0,f		;rotate Var to the left

	btfss 	STATUS,C	;carry = 1 ?
	bcf		Data1		;if not set line to 0
	btfsc	STATUS,C	;is carry = 0 ?
	bsf		Data1		;if not set, set data line to 1

	bsf		Clock1		; generate 1 clock
	nop
	bcf		Clock1
	
	decfsz	Var2,f		;bits been sent ?
	goto	Loop		;if not repeat
	

	endm
if somebody wants to play with it I'll post the circuit if not I'll not waste my time drawing it out. I used a 74hc164 for the rolls and 2 74hc595 for col. and 3 75492PE led drivers.
 
It took me A long time I can make it spell letters but just 1 at a time I want to just save the roll hex in a table and just let it keep loading letters . But I don't no how to do that now I say it's a array that I need to use.
 
It took me A long time I can make it spell letters but just 1 at a time I want to just save the roll hex in a table and just let it keep loading letters . But I don't no how to do that now I say it's a array that I need to use.

You need a table, an array is really a high level construct - check my scrolling LED tutorial with tables for the character set and for the message.
 
would something like this work for the table
Code:
Roll4:
	call    shifrolls			;fill tx buffer
	movwf	TX1
	HC164   TX1,CountSPI1
	return
delay:
		;29998 cycles
	movlw	0x6F
	movwf	d1
	movlw	0x18
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0

			;2 cycles
	goto	$+1
	return
shifrolls:
     movwf     temp
     movlw     high wordsout     ; get high order part of the beginning of the table
     movwf     PCLATH
     movlw     low wordsout      ; load starting address of table
     addwf     temp,w              ; add offset
     btfsc     STATUS,C            ; did it overflow?
     incf      PCLATH,f            ; yes: increment PCLATH
     movwf     PCL                 ; modify PCL
wordsout:
     retlw     0x00        ; 0
     retlw     0x01        ; 1
     retlw     0x02        ; 2
     retlw     0x04        ; 3
     retlw     0x08        ; 4
     retlw     0x10        ; 5
     retlw     0x20        ; 6
     retlw     0x40        ; 7
    
	end							; Program code stops here
 
That didn't work it loads the first hex and get lost there I think it something to do with page boundary
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top