SUB a1_data()
FOR index = 0 TO bound(anodes_data)
Anodes_data(index)= A_Data(index)
NEXT '0
END SUB
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/22/2014 *
* Version : 1.0 *
* Notes : LONG and SHORT of multi plexing *
* : *
*****************************************************************************
}
DEVICE = 18F2420
CLOCK = 8
// import LCD library...
'INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
'INCLUDE "shift.bas"
INCLUDE "SUART.bas"
// Arrays
INCLUDE "convert.bas"
INCLUDE "convert.bas"
CONST A_Data(9)AS BYTE =(%00000000, // K
%01000100,
%01001000,
%01010000,
%01100000,
%01010000,
%01001000,
%01000100,
%00000000)
CONST Cathodes_Data(9)AS BYTE = (%01111111, ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
%10111111,
%11011111,
%11101111,
%11110111,
%11111011,
%11111101,
%11111110,
%11111111)
{
SUB Assign(BYREFCONST array() AS BYTE)
DIM index AS BYTE
DIM Anodes_Data(9) AS BYTE
Anodes_Data = array
FOR index = 0 TO BOUND(Anodes_Data)
'USART.Write("Value = %", BinToStr(Anodes_Data(index), 8),13,10)
NEXT
END SUB
}
' program start...
' dim cathodes_data(9) as byte
DIM Anodes_data(9) AS BYTE
DIM index AS BYTE
'DIM Anodes_data(9) AS BYTE
DIM y AS BYTE
DIM x AS BYTE
// Sub Routines
'USART.SetBaudrate(br9600)
SetTX(PORTC.6)
SetRX(PORTC.7)
SetBaudrate(sbr9600)
SetMode(umTrue)
UART.SetTX(PORTB.7) ' matches the PICkit 2 UART tool input pin when connected to the ICSP connector
// Start Of Program
'portc = 0
'portb = 1
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTD all outputs
TRISB = %00000000 // Make PORTB all outputs
y = 0
// Main Loop
WHILE True()
anodes_data = A_Data
' SHORT VERSION
FOR x = 0 TO 7
' FOR index = 0 TO 64 STEP 8
portc = Anodes_data(x) 'LOAD Anodes data
portb = Cathodes_Data(x) 'TURN ON CATHODES
DELAYMS(1)
portc = Anodes_data(8) 'turn off Anodes data
NEXT
' portc = %00000000 ' eliminate ghosting
wend
{
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'LONG VERSION
portc = Anodes_data(0) 'LOAD Anodes data COLUM 1
portb = Cathodes_Data(0) 'TURN ON CATHODES COLUM 1
' DELAYMS(5)
portc = Anodes_data(8) 'turn off Anodes data COLUM 1
portc = Anodes_data(1) 'LOAD Anodes data COLUM 2
portb = Cathodes_Data(1) 'TURN ON CATHODES COLUM 2
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 2
portc = Anodes_data(2) 'LOAD Anodes data COLUM 3
portb = Cathodes_Data(2) 'TURN ON CATHODES COLUM 3
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 3
portc = Anodes_data(3) 'LOAD Anodes data COLUM 4
portb = Cathodes_Data(3) 'TURN ON CATHODES COLUM 4
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 4
portc = Anodes_data(4) 'LOAD Anodes data COLUM 5
portb = Cathodes_Data(4) 'TURN ON CATHODES COLUM 5
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 5
portc = Anodes_data(5) 'LOAD Anodes data COLUM 6
portb = Cathodes_Data(5) 'TURN ON CATHODES COLUM 6
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 6
portc = Anodes_data(6) 'LOAD Anodes data COLUM 7
portb = Cathodes_Data(6) 'TURN ON CATHODES COLUM 7
delayms(10)
portc = Anodes_data(8) 'turn off Anodes data COLUM 1
portc = Anodes_data(7) 'LOAD Anodes data COLUM 2
portb = Cathodes_Data(7) 'TURN ON CATHODES COLUM 2
delayms(10)
' UART.Write("x =", binToStr(A_Data(x),13,10))
' portc = %00000000
//44444444444444444444444444444444444444
WEND // Loop back to the while loop as long as we havent finished.
anodes_data = A_Data
' SHORT VERSION
FOR x = 0 TO 7
' FOR index = 0 TO 64 STEP 8
portc = Anodes_data(x) 'LOAD Anodes data
portb = Cathodes_Data(x) 'TURN ON CATHODES
DELAYMS(1)
portc = Anodes_data(8) 'turn off Anodes data
NEXT
' portc = %00000000 ' eliminate ghosting
Toyman - re-posting working code that I have already posted is of no use whatsoever. A specific request was made for you to post your code and we would try and help. I do not want this or any other thread on the Swordfish forum to degenerate like threads I have seen on other forums. I would respectfully ask all other users to only make a contribution if it will help this thread move closer to a solution. If invalid, inappropriate or just useless snippets of code are posted by the starter of this thread, then please refrain from posting any sort of reply at all, allowing us all to move on to more productive tasks...
{
*****************************************************************************
* Name : testing routine.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 2/4/2014 *
* Version : 1.0 *
* Notes : letter testing routine *
* : *
*****************************************************************************
}
DEVICE = 18F2420
CLOCK = 8
// import LCD library...
INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "shift.bas"
// Arrays
// Arrays
CONST CAT_Data(8)AS BYTE = (%11111110, ' top to bottom bit 7 = left
%11111101,
%11111011,
%11110111,
%11101111,
%11011111,
%10111111,
%01111111)
CONST B_Data(8)AS BYTE = (%01111111, 'top left
%10111111,
%11011111, 'cathodes
%11101111,
%11110111,
%11111011,
%11111101,
%11111110) 'bottom right
CONST ARRAYB (8) AS BYTE= (%10000000, 'left to right bit 7 = left
%10000000,
%10000000,
%10000000,
%10000000, 'anodes
%00000100,
%00000010,
%00000001)
CONST T_Data(9)AS BYTE = (%11111111, // T
%00010000,
%00010000,
%00010000,
%00010000,
%00000000,
%00000000,
%00000000,
%00000000)
CONST Tc_Data(9)AS BYTE = (%00000000, // T
%11101111,
%11101111,
%11101111,
%11101111,
%00000000,
%00000000,
%00000000,
%00000000)
{
SUB Display(BYREFCONST array() AS BYTE)
DIM index AS BYTE
FOR index = 0 TO BOUND(array)
portc = ARRAYA (index)
NEXT
END SUB
}
// variable declaration
DIM x AS BYTE
DIM y AS BYTE
DIM index AS BYTE
DIM indexb AS BYTE
DIM bits AS BYTE
DIM C(64) AS BYTE
DIM b(64) AS BYTE
// Sub Routines
y = 0
// Start Of Program
'portc = 0
'portb = 1
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTD all outputs
TRISB = %00000000 // Make PORTB all outputs
'index = 7
// Main Loop
WHILE True()
FOR index = 0 TO 7 ' anodes byte
FOR x = 0 TO 7 ' anodes bit
portc =T_Data(index).bits (x) ' index changes the CONST array byte. The bits(x) turns each LED on /off in the byte that index has.
portb =CAT_Data(x) ' This scans the cathodes
DELAYMS(500) ' have it slowed down to SEE what is actually going on.
NEXT
NEXT
WEND // Loop back to the while loop as long as we havent finished.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?