Write longer messages on Matrix

Post here to discuss The Great Race.

Moderators: Chuckt, Garth, bitfogav

Post Reply
nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am

Write longer messages on Matrix

Post by nodoubtman » Thu Aug 23, 2012 11:15 pm

I would like to write longer message like this :
'Marc Paradis électronique :)', but it cuts in after the u ' and loop back :( i don't know why, i would like to write some complete sentences, is there a way? thanks a bunch! :)

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;											;
;	The scroller							;
;											;
;   this is made for the 8x8 display		;
;											;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


	LIST p=16f628a 				;	tell assembler what chip we are using
	include "P16f628a.inc"		;	include the defaults for the chip
	__config 0x3f18				;	sets the configuration settings (oscillator type etc.)

;==================================================================================================================================

	
	 errorlevel -302

PC equ 0x02					;	The program counter will be refered to as PC

	cblock 0x20				;	start of general purpose registers - this is where we start defining variable names
	
		counta				;	used in the delay routines
		countb 				;	used in the delay routines
		pc_track			;	this is our track data program counter
	
		vram_1				;	a video ram location
		vram_2				;	a video ram location
		vram_3				;	a video ram location
		vram_4				;	a video ram location
		vram_5				;	a video ram location
		vram_6				;	a video ram location
		vram_7				;	a video ram location
		vram_8				;	a video ram location
	
		vtemp_1				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_2				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_3				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_4				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_5				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_6				;	a temporary video ram location (used when tranfering vram data to the next vram location)
		vtemp_7				;	a temporary video ram location (used when tranfering vram data to the next vram location)
	
		repeat_frame		;	used to determine how many times we will be repeating each 'frame'
	
	endc					;	end of general purpose registers

;==================================================================================================================================

	org 0x0000					;	org sets the origin, 0x0000 for the 16F628,

	movlw h'07'					;	Turn comparators off	
	movwf CMCON 				;	(we just want to use the ports as digital ports)


	bsf STATUS, RP0 			;	select bank 1 (to enable us to change the Input / Output status of our ports)
	movlw b'00000000' 			;	set PORTB all outputs (A '0' means output, A '1' means input. We can set each
	movwf TRISB					;	We can set each bit individualy. Each port having 8-bits or 8 pins.
	movlw b'00100000' 			;	set PORTA all outputs except for bit 5. Bit 5 is an input ONLY pin.
	movwf TRISA 				;	It cannot be set to an output!
	bcf STATUS, RP0 			;	select bank 0


	goto setup					; go straight to the setup routine

;==================================================================================================================================



track_message					;	Here's our letter data!

	incf pc_track, f			;	increment pc_track by one and then
	movf pc_track, w			;	move it into our working register THEN

	addwf PC					;	add this number to our program counter
	nop							;	skip one step...

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;  Draw data on matrix

; HERE IS WHERE YOU ENTER YOUR DATA TO DISPLAY ON THE 8x8 MATRIX


	retlw b'00000000'
	retlw b'00000000'
	retlw b'00000000'				; space before we draw the data on the Matrix
	retlw b'00000000'
	retlw b'00000000'
	retlw b'00000000'
	retlw b'00000000'
	
	; m
	retlw b'00000000'	
	retlw b'01101100'	
	retlw b'01011100'	
	retlw b'01010100'	
	retlw b'01010100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; a
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'
	
	; r
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01001000'	
	retlw b'01010000'	
	retlw b'01001000'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; c
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; p
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01001000'	
	retlw b'01110000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; a
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; r
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01001000'	
	retlw b'01010000'	
	retlw b'01001000'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; a
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; d
	retlw b'00000100'	
	retlw b'00000100'	
	retlw b'00000100'	
	retlw b'00111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; i
	retlw b'00000000'	
	retlw b'00010000'	
	retlw b'00000000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; s
	retlw b'00000000'	
	retlw b'01111000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'00111000'	
	retlw b'00001000'	
	retlw b'01111000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; e
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01110000'	
	retlw b'01000000'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; l
	retlw b'00000000'	
	retlw b'00100000'	
	retlw b'00100000'	
	retlw b'00100000'	
	retlw b'00100000'	
	retlw b'00100000'	
	retlw b'00111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; e
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01110000'	
	retlw b'01000000'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'


	; c
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; t
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	
	; r
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01001000'	
	retlw b'01010000'	
	retlw b'01001000'	
	retlw b'01000100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; o
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'


	; n
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'01000000'	
	retlw b'01111000'	
	retlw b'01001000'	
	retlw b'01001000'	
	retlw b'01001000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; i
	retlw b'00000000'	
	retlw b'00010000'	
	retlw b'00000000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00010000'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; q
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000100'	
	retlw b'01000100'	
	retlw b'01111100'	
	retlw b'00000100'	
	retlw b'00000100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; u
	retlw b'00000000'	
	retlw b'00100100'	
	retlw b'00100100'	
	retlw b'00100100'	
	retlw b'00100100'	
	retlw b'00100100'	
	retlw b'00111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; e
	retlw b'00000000'	
	retlw b'01111100'	
	retlw b'01000000'	
	retlw b'01000000'	
	retlw b'01110000'	
	retlw b'01000000'	
	retlw b'01111100'	
	retlw b'00000000'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

	; brad smile
	retlw b'00111100'	
	retlw b'01000010'	
	retlw b'10100101'	
	retlw b'10000001'	
	retlw b'10100101'	
	retlw b'10011001'	
	retlw b'01000010'	
	retlw b'00111100'	
	retlw b'00000000'	
	retlw b'00000000'				; space between numbers				
	retlw b'00000000'

; END OF DATA 
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

setup								;	Okay, lets get everything setup, ready to play!
	movlw b'00000000'				;	setup PORTA so that the 7442 ports are all ground inputs.
	movwf PORTA						;	and also send out a logic 1 to the red column of led cathodes (so they wont turn on)
	clrf PORTB						;	we dont want any data on the screen just yet - so clear PORTB
	clrf vram_1						;	these next lines clear our video ram.
	clrf vram_2						;	if we didnt clear them, then we would get random
	clrf vram_3						;	dots on our screen at startup and would more than likely crash
	clrf vram_4						;	as soon as we started playing! (experiment with not
	clrf vram_5						;	clearing all these vrams and see what happens!)
	clrf vram_6						;	....
	clrf vram_7						;	....
	clrf vram_8						;	....

	clrf pc_track					;	clear pc_track (so we start from the top of this data

begin								;	the main program!
	call display					;	call the display routine
	call fill_vram					;	call the fill video ram routine
	goto begin						;	do it all again!

;==================================================================================================================================


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																	;
;	The next routine basically takes care of drawing the actual		;
;	graphics on the screen. You will notice that there are eight 	;
;	"sections" here'. they basically look the same except for		;
;	minor differences. Thats because they are all doing the same	;
;	thing - activating a certain row of cathodes and then grabbing	;
;	the anode data in order to turn the leds on. The only			;
;	difference between them is that each section activates a		;
;	different row of cathodes and also grabs it's data to be		;
;	displayed from a different vram location.						;
;																	;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

display	
			movlw d'25'						;	We need to set the speed that we are scrolling at,
			movwf repeat_frame				;	so we grab that data from speed and copy it to our frame_rate
loop

			movlw b'00000111'
			movwf PORTA
			movf vram_1, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000110'
			movwf PORTA
			movf vram_2, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000101'
			movwf PORTA
			movf vram_3, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000100'
			movwf PORTA
			movf vram_4, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000011'
			movwf PORTA
			movf vram_5, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000010'
			movwf PORTA
			movf vram_6, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000001'
			movwf PORTA
			movf vram_7, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB
										
			movlw b'00000000'
			movwf PORTA
			movf vram_8, w					;	Now we grab the first COLUMN of data from vram_1.
			movwf PORTB						;	then we copy it to PORTB
			call delay						;	Call the delay (to hold that one row ON for a split second)
			clrf PORTB


		
		decfsz repeat_frame					;	then decrease repeat_frame by one, 
		goto loop							;	if its not zero then draw it all again!

	return									;	if it is zero, then go back to where we came from...


;==================================================================================================================================

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																	;
;	This next section basically 'fills' the	video ram locations		;
;	with the data from the previous video ram location - This is	;
;	how we get the screen to scroll. It also grabs a new byte of	;
;	data from the track data table to display in video ram 1.		;							
;																	;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

fill_vram
		movf vram_1, 0					;	Copy vram_1 into vtemp_1 to use as a backup
		movwf vtemp_1					;	storage location. (just before we overwrite vram_1)
		movf vram_2, 0					;	Copy vram_1 into vtemp_2 to use as a backup
		movwf vtemp_2					;	storage location. (just before we overwrite vram_2)
		movf vram_3, 0					;	Copy vram_1 into vtemp_3 to use as a backup
		movwf vtemp_3					;	storage location. (just before we overwrite vram_3)
		movf vram_4, 0					;	Copy vram_1 into vtemp_4 to use as a backup
		movwf vtemp_4					;	storage location. (just before we overwrite vram_4)
		movf vram_5, 0					;	Copy vram_1 into vtemp_5 to use as a backup
		movwf vtemp_5					;	storage location. (just before we overwrite vram_5)
		movf vram_6, 0					;	Copy vram_1 into vtemp_6 to use as a backup
		movwf vtemp_6					;	storage location. (just before we overwrite vram_6)
		movf vram_7, 0					;	Copy vram_7 into vtemp_7 to use as a backup
		movwf vtemp_7					;	storage location. (just before we overwrite vram_7)

;==================================================================================================================================

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																	;
;	Did you notice that we don't need to make a backup of vram_8?	;
;	That's because there are only 8 lines on the screen. So after 	;
;	we display the 8th line, it is then shifted out of the screen.	;
;																	;
;	Now that we have backed up our old vram data, we then need to	;
;	copy them to the next successive vram location - this basically	;
;	shifts everything on the screen down one space. It also grabs	;
;	a brand new byte of data and copies it into vram_1 (which		;
;	means it will be displayed at the top of the screen, before		;
;	It gets shifted again...										;
;																	;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		call track_message
		movwf vram_1					;	then copy the new byte of data to the first vram location
		movf vtemp_1, 0					;	copy what was in vram_1 into vram_2 (remember how we made
		movwf vram_2					;	a backup of vram_1 and called it vtemp_1.)
		movf vtemp_2, 0					;	copy what was in vram_2 into vram_3 (remember how we made
		movwf vram_3					;	a backup of vram_2 and called it vtemp_2.)
		movf vtemp_3, 0					;	copy what was in vram_3 into vram_4 (remember how we made
		movwf vram_4					;	a backup of vram_3 and called it vtemp_3.)
		movf vtemp_4, 0					;	copy what was in vram_4 into vram_5 (remember how we made
		movwf vram_5					;	a backup of vram_4 and called it vtemp_4.)
		movf vtemp_5, 0					;	copy what was in vram_5 into vram_6 (remember how we made
		movwf vram_6					;	a backup of vram_5 and called it vtemp_5.)
		movf vtemp_6, 0					;	copy what was in vram_6 into vram_7 (remember how we made
		movwf vram_7					;	a backup of vram_6 and called it vtemp_6.)
		movf vtemp_7, 0					;	copy what was in vram_7 into vram_8 (remember how we made
		movwf vram_8					;	a backup of vram_7 and called it vtemp_7.)
	return								;	Now that we're all done here, go back to our main program.

;==================================================================================================================================


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																	;
;	Heres the delay routines!										;
;																	;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


delay									;	This first delay is a rather fast one.
			movlw d'02'					;	You can make the delay longer by			#### the higher the value, the more the matrix will flicker ####
			movwf counta				;	increasing the decimal value. Or you
			movwf countb				;	can make the delay shorter by decreasing
again	decfsz counta, 1				;	the decimal value.
			goto again					;
			decfsz countb, 1			;
			goto again					;	once counta and countb have reached zero
	return								;	it will return to the main program


	end									;	That's it!
thanks for the big help!
marC:)



*EDITED By Bitfogav - moved to new topic*

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am

Re: Write longer messages on Matrix

Post by nodoubtman » Fri Aug 24, 2012 1:54 am

*EDITED By Bitfogav - moved to new topic*
bigof , can you help me?

thank U!
marC:)

User avatar
bitfogav
Moderator
Moderator
Posts: 908
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Write longer messages on Matrix

Post by bitfogav » Fri Aug 24, 2012 1:55 am

nodoubtman wrote: I would like to write longer message like this :
'Marc Paradis électronique :)', but it cuts in after the u ' and loop back :( i don't know why, i would like to write some complete sentences, is there a way? thanks a bunch! :)

thanks for the big help!
marC:)
No its not possible to make long sentences, has the Program Counter is only limited to 255 counts, so when the Program Counter reaches 255 it will then jump over to Zero again and thats why the message is looping back to the start when it gets to the letter "U".

The part of code below is where our Program Counter is increased, so the max "retlw" commands we are allowed is 255.

Code: Select all

track_message               ;   Here's our letter data!

   incf pc_track, f         ;   increment pc_track by one and then
   movf pc_track, w         ;   move it into our working register THEN

   addwf PC               ;   add this number to our program counter
   nop                     ;   skip one step...

;  Draw data on matrix

; HERE IS WHERE YOU ENTER YOUR DATA TO DISPLAY ON THE 8x8 MATRIX


1.   retlw b'00000000'      <--- max number of retlw = 255.
2.   retlw b'00000000'       <---
                                 <---
     "  "   "   "   "   "   "    <---
254. retlw b'00000000'       <---
255.  retlw b'00000000'      <--- 
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am

Re: Write longer messages on Matrix

Post by nodoubtman » Fri Aug 24, 2012 1:56 am

bitfogav wrote: No its not possible to make long sentences, has the Program Counter is only limited to 255 counts, so when the Program Counter reaches 255 it will then jump over to Zero again and thats why the message is looping back to the start when it gets to the letter "U".
can we increase the program counter like 500 ?

thank you!
marC:)

User avatar
bitfogav
Moderator
Moderator
Posts: 908
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Write longer messages on Matrix

Post by bitfogav » Fri Aug 24, 2012 2:02 am

No sorry marC, the Program Counter is only 1 data byte, so the maximum it can count up to is 255.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am

Re: Write longer messages on Matrix

Post by nodoubtman » Fri Aug 24, 2012 2:20 am

bitfogav wrote:No sorry marC, the Program Counter is only 1 data byte, so the maximum it can count up to is 255.
oh ok, i see..
so :
PC equ 0x02
0x02 = 255?

thank you!
marC:)

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Write longer messages on Matrix

Post by brad » Sat Aug 25, 2012 10:25 pm

It looks like you have found one of the BIG limitations of using 16F microcontrollers. I remember having this exact problem years ago...

If you use 18F pics you won't have this problem at all.

An 18F pic coded in swordfish basic is by and far the best way to go. i have tried many other programming languages and variants.

I highly recommend checking out http://www.digital-diy.com for tutorials on how to code in swordfish basic. You will find it so much easier to achieve all these goals that you have.

One day (when I get time) I will be making my own tutorials based around 18F pics and swordfish basic and will certainly contain LED matrix displays. Unfortunately that won't be for a while though.

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Write longer messages on Matrix

Post by Mike M » Wed Dec 19, 2012 3:52 pm

It's not really that difficult to use tables larger than 256 bytes and/or tables that can be placed almost anywhere in program memory (and which can straddle 256 word memory boundaries) on the 16F devices.

For those who may be interested, here's an untested example program for the 16F648A+7442 Great Race hardware which demonstrates one of many ways you might scroll a larger message. Note that a small data bender routine is used in this program to scroll the contents of the 'vram' video buffer from right-to-left on the display instead of from top-to-bottom (so you don't have to rotate the display 90 degrees when switching from a game display to a scrolling message display, or vice-versa).

Cheerful regards, Mike

Code: Select all

;******************************************************************
;                                                                 *
;   Filename: Scroller v2.asm                                     *
;     Author: Mike McLaren, K8LH                                  *
;           : Micro Application Consultants                       *
;       Date: 13-Dec-2012                                         *
;                                                                 *
;  Simple Message Display For Brad's 16F648A + 7442 8x8 Matrix    *
;  Uses A 16-Bit Table Pointer For Displaying Larger Messages.    *
;                                                                 *
;      MPLab: 8.84    (tabs=8)                                    *
;      MPAsm: 5.44                                                *
;                                                                 *
;******************************************************************

   include "P16f648a.inc"
   __config _WDT_OFF&_LVP_OFF&_MCLRE_OFF&_BOREN_OFF&_INTOSC_OSC_NOCLKOUT

   list st=off      ; turn symbol table off in LST file
   errorlevel -302  ; disable bank warning messages
   radix dec        ; use decimal numbers
;
;  variables
;
        cblock 0x20
vram:8              ; video ram, char vram[8]
ptrl                ; message table pointer lo
ptrh                ; message table pointer hi
bent                ; holds 'bended' row data
repeat              ; video repeat (scroll speed)
        endc

;==================================================================
;  K8LH DelayCy() subsystem macro generates two instructions      =
;==================================================================

clock   equ     4               ; 4, 8, 12, 16, or 20 MHz clock
usecs   equ     clock/4         ; cycles/usec operand multiplier
        radix   dec

DelayCy macro   cycles          ; 8..1031 cycle range
        movlw   ~((cycles-8)/4)
        call    uDelay-(cycles%4)
        endm

;******************************************************************
;  main init                                                      *
;******************************************************************

        org     0x0000
init
        clrf    STATUS          ; bank 0                          |B0
        movlw   h'07'           ;                                 |B0
        movwf   CMCON           ; comparator off, digital I/O     |B0
;
;  configure and initialize I/O ports
;
        bsf     STATUS,RP0      ; bank 1                          |B1
        clrf    TRISA           ; porta all outputs               |B1
        clrf    TRISB           ; portb all outputs               |B1
        bcf     STATUS,RP0      ; bank 0                          |B0
        movlw   b'00001000'     ;                                 |B0
        movwf   PORTA           ; 7442 address 0 (red leds off)   |B0
        clrf    PORTB           ; blank the display               |B0
;
;  initialize program variables
;
        clrf    vram+0          ; vram[0] = 0                     |B0
        clrf    vram+1          ; vram[1] = 0                     |B0
        clrf    vram+2          ; vram[2] = 0                     |B0
        clrf    vram+3          ; vram[3] = 0                     |B0
        clrf    vram+4          ; vram[4] = 0                     |B0
        clrf    vram+5          ; vram[5] = 0                     |B0
        clrf    vram+6          ; vram[6] = 0                     |B0
        clrf    vram+7          ; vram[7] = 0                     |B0
        movlw   msgtbl/256      ; msgtbl address hi               |B0
        movwf   ptrh            ; msgtbl pointer hi               |B0
        movlw   msgtbl%256      ; msgtbl address lo               |B0
        movwf   ptrl            ; msgtbl pointer lo               |B0

;******************************************************************
;  main loop                                                      *
;******************************************************************

loop
        movlw   25              ; adjusting this value effects    |B0
        movwf   repeat          ; message scrolling speed         |B0
refresh
        movlw   b'00001000'     ; 7442 address 0 (red leds off)   |B0
        movwf   PORTA           ; set 7442 address to row 0       |B0
;
;  refresh all eight rows, one row at a time
;
nextrow
        call    bender          ; get 'bended' row data           |B0
        movwf   PORTB           ; display new row for...          |B0
        DelayCy(750*usecs-1)    ; 750 usecs minus 1 cycle         |B0
        clrf    PORTB           ; blank the display               |B0
        incf    PORTA,F         ; increment 7442 row address      |B0
        btfsc   PORTA,3         ; last row? yes, skip, else       |B0
        goto    nextrow         ; refresh another row             |B0

        decfsz  repeat,F        ; repeat? no, skip (done), else   |B0
        goto    refresh         ; do another full refresh cycle   |B0
;
;  scroll display (shift video buffer)
;
        movf    vram+6,W        ;                                 |B0
        movwf   vram+7          ; vram[7] = vram[6]               |B0
        movf    vram+5,W        ;                                 |B0
        movwf   vram+6          ; vram[6] = vram[5]               |B0
        movf    vram+4,W        ;                                 |B0
        movwf   vram+5          ; vram[5] = vram[4]               |B0
        movf    vram+3,W        ;                                 |B0
        movwf   vram+4          ; vram[4] = vram[3]               |B0
        movf    vram+2,W        ;                                 |B0
        movwf   vram+3          ; vram[3] = vram[2]               |B0
        movf    vram+1,W        ;                                 |B0
        movwf   vram+2          ; vram[2] = vram[1]               |B0
        movf    vram+0,W        ;                                 |B0
        movwf   vram+1          ; vram[1] = vram[0]               |B0
        call    rdtable         ; get next table element          |B0
        movwf   vram+0          ; vram[0] = rdtable();            |B0
        incf    ptrl,F          ; bump table pointer lo           |B0
        skpnz                   ; overflow? no, skip, else        |B0
        incf    ptrh,F          ; bump table pointer hi           |B0
        goto    loop            ; loop forever                    |B0

;******************************************************************
;                                                                 *
;******************************************************************

rdtable
        movf    ptrh,W          ; pointer hi                      |B0
        movwf   PCLATH          ; setup PC hi                     |B0
        movf    ptrl,W          ; pointer lo                      |B0
        movwf   PCL             ; write PC lo (jump into table)   |B0

;******************************************************************
;  K8LH DelayCy() subsystem 8 bit timing subroutine               *
;******************************************************************

        nop                     ; entry point for (delay%4) == 3  |B0
        nop                     ; entry point for (delay%4) == 2  |B0
        nop                     ; entry point for (delay%4) == 1  |B0
uDelay  addlw   1               ; entry point for (delay%4) == 0  |B0
        skpz                    ; overflow? yes, skip, else       |B0
        goto    uDelay          ; branch (4 cycle loop)           |B0
        return                  ;                                 |B0

;******************************************************************
;  data bender allows scrolling vram[] side-ways on the display   *
;******************************************************************

bender
        rrf     vram+7,W        ;                                 |B0
        rrf     vram+7,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+6,W        ;                                 |B0
        rrf     vram+6,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+5,W        ;                                 |B0
        rrf     vram+5,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+4,W        ;                                 |B0
        rrf     vram+4,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+3,W        ;                                 |B0
        rrf     vram+3,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+2,W        ;                                 |B0
        rrf     vram+2,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+1,W        ;                                 |B0
        rrf     vram+1,F        ;                                 |B0
        rlf     bent,F          ;                                 |B0
        rrf     vram+0,W        ;                                 |B0
        rrf     vram+0,F        ;                                 |B0
        rlf     bent,W          ;                                 |B0
        return                  ;                                 |B0

;******************************************************************
;  message table                                                  *
;******************************************************************

msgtbl
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'M'
        retlw   b'00000010'
        retlw   b'01111100'
        retlw   b'00000010'
        retlw   b'01111111'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'E'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'01000001'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'R'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'01110110'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'R'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'01110110'
        retlw   b'00000000'
        retlw   b'00000111'     ; 'Y'
        retlw   b'00001000'
        retlw   b'01110000'
        retlw   b'00001000'
        retlw   b'00000111'
        retlw   b'00000000'
        retlw   b'00000000'     ; ' '
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00111110'     ; 'C'
        retlw   b'01000001'
        retlw   b'01000001'
        retlw   b'01000001'
        retlw   b'00100010'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'H'
        retlw   b'00001000'
        retlw   b'00001000'
        retlw   b'00001000'
        retlw   b'01111111'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'R'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'01110110'
        retlw   b'00000000'
        retlw   b'01000001'     ; 'I'
        retlw   b'01111111'
        retlw   b'01000001'
        retlw   b'00000000'
        retlw   b'00000110'     ; 'S'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'00110000'
        retlw   b'00000000'
        retlw   b'00000001'     ; 'T'
        retlw   b'00000001'
        retlw   b'01111111'
        retlw   b'00000001'
        retlw   b'00000001'
        retlw   b'00000000'
        retlw   b'01111111'     ; 'M'
        retlw   b'00000010'
        retlw   b'01111100'
        retlw   b'00000010'
        retlw   b'01111111'
        retlw   b'00000000'
        retlw   b'01111110'     ; 'A'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'00001001'
        retlw   b'01111110'
        retlw   b'00000000'
        retlw   b'00000110'     ; 'S'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'01001001'
        retlw   b'00110000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
        retlw   b'00000000'
;
;  last entry resets pointer to the beginning of the table
;
        movlw   msgtbl/256      ; msgtbl address hi               |B0
        movwf   ptrh            ; reset pointer hi                |B0
        movlw   msgtbl%256      ; msgtbl address lo               |B0
        movwf   ptrl            ; reset pointer lo                |B0
        goto    rdtable         ; return msgtbl[0] data           |B0

;******************************************************************
        end

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Write longer messages on Matrix

Post by brad » Thu Dec 20, 2012 9:11 am

Thanks for the great info there Mike!

To be honest, years ago I was stumped with this sort of problem and wasn't sure how to fix it. That was my main reason for making the move to 18f pics with swordfish. I have since tried other languages but Swordfish is by far my favourite!

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Write longer messages on Matrix

Post by Mike M » Thu Dec 20, 2012 9:48 pm

brad wrote:Thanks for the great info there Mike!
You're welcome and thank you for coming up with such a simple and cool game idea. I built a "single chip" version of it using a 16F1828 that works quite nicely. Better late than never, right (lol)?

Cheerful regards, Mike

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Write longer messages on Matrix

Post by brad » Fri Dec 21, 2012 10:48 am

Great to hear you've built your own version :) any chance of a photo or did you perhaps make a video?

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Write longer messages on Matrix

Post by Mike M » Fri Dec 21, 2012 12:35 pm

brad wrote:Great to hear you've built your own version :) any chance of a photo or did you perhaps make a video?
Ok, here's a picture of my single chip prototype (below). No video yet. I only just wired up a pair of switches this afternoon (mux'd off a couple row driver lines) and now I can move my car left and right (yippee!). I could post a schematic (showing all eight parts) later, in a new thread, if anyone is interested?

Happy Holidays and cheerful regards, Mike
Attachments
Race Car #1.png
Race Car #1.png (821.19 KiB) Viewed 11523 times

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Write longer messages on Matrix

Post by brad » Sat Dec 22, 2012 8:21 pm

Nice and compact - Great job!

If you get some spare time it would be great if you could upload whatever details you have of your project in a new thread :)

Mike M
decided to stick around...
decided to stick around...
Posts: 27
Joined: Thu Dec 13, 2012 3:19 am
Location: Michigan, USA

Re: Write longer messages on Matrix

Post by Mike M » Sat Dec 22, 2012 9:43 pm

Happy to... Can you delete the picture post above? It doesn't really belong in this thread, does it? Sorry...

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Write longer messages on Matrix

Post by brad » Mon Dec 24, 2012 10:34 pm

Now it makes sense. I thought this post was a different post... When i get to my computer i can delete these last few posts. Im on my phone at the moment.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest