PIC Code in Bascom AVR übersetzen
Hallo,
kann mir mal jemand unter die Arme greifen,
möchte folgenden PIC Code in Bascom AVR übersetzen !!
Bin Anfänger
Gruß Gerhardt
Code:
**************************************************************
* Name : HDSP2112.BAS
*
* : Tested with HDSP-2112 Display & PIC16F877
****************************************************************
DEFINE OSC 20 ' 20MHz oscillator
DEFINE LOADER_USED 1' Using boot-loader for initial prototype
TRISA = 0 ' Setup PortA = output for Address Bus
TRISB = 0 ' Setup PortB = output for Data Bus
TRISC = $80 ' RC.7 = input, rest outputs [used for loader]
ADCON1 = 7 ' A/D OFF
A_Bus VAR PortA ' PortA Address Bus
D_Bus VAR PortB ' PortB = Data Bus
W_Pin VAR PortC.0 ' HDSP-2112 write strobe pin #13
A3 VAR PortC.1 ' HDSP-2112 mode select pin #6
RST VAR PortC.2 ' HDSP-2112 reset pin #1
Digit VAR BYTE[8] ' 8-byte digit array
DigPat VAR BYTE ' Digit pattern from lookup table
LP_Cnt VAR BYTE ' Loop counter
LowDig VAR BYTE ' Holds "low" digit # to lookup
LowDig = 0 ' 1st digit = 0
HiDig VAR BYTE ' Holds "high" digit # to lookup
HiDig = 7 ' Last digit = 7
J VAR BYTE ' Array index pointer
J = 0 ' 1st byte in array
S_Speed VAR WORD ' Holds display scroll speed
S_Speed = 300 ' Set display scroll speed here
LOW D_Bus.7 ' Set display for normal operation
EOM CON "~" ' Character used as "End of Message" marker
'* // Initialize display - then set brightness * //'
Init_Display:
' * // Initialize Display Here * //'
HIGH W_Pin : LOW RST : PAUSE 10 : HIGH RST : PAUSE 10
' * // Set Display Brightness Here * //'
' To change display brightness
' D_Bus = | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
' Bright =| 100% | 80% | 53% | 40% | 27% | 20% | 13% |
'
' Set 27% | mode.bit | strobe settings into display |
D_Bus = 4 : LOW A3 : LOW W_Pin : HIGH W_Pin
HIGH A3 ' A3 used only for setting display brightness
'* // Get 8 digits into "Digit Array" for display * //'
GetDig:
FOR LP_Cnt = LowDig TO HiDig
LOOKUP LP_Cnt,[" Hello.! ~"],DigPat
Digit[J] = DigPat ' Load all 8 digits into array
J = J + 1 ' Increment array index pointer
NEXT ' Loop until we have all 8 digits loaded
J=0 ' Re-set array index pointer
LowDig = LowDig + 1 ' Increment to next "low" digit
HiDig = HiDig + 1 ' Increment to next "high" digit
' * // We're using the "~" character in EOM to tag the end of message * //'
IF Digit[7] = EOM THEN ' End-of-message indicator..?
Digit[7] = " " ' Then load a "blamk space" character
LowDig = 0 ' Re-load 0-7 MAX digit count
HiDig = 7 '
ENDIF
'* // Display 8 digits on display then return for more // *'
DisplayDigit:
FOR LP_Cnt = 0 TO 7 ' Scroll right-to-left
A_Bus = LP_Cnt ' Place digit address on address bus
D_Bus = Digit[J] ' Place digit data on data bus
LOW W_Pin : HIGH W_Pin' Strobe data into display
J = J + 1 ' Increment array pointer to next digit
NEXT
J = 0 ' Re-set array index pointer
PAUSE S_Speed ' Set display scroll speed
GOTO GetDig
'* // Display connections * //'
' PortB Display | PortA Display | PortC Display
' B0 #19 | A0 #3 | C0 #13
' B1 #20 | A1 #4 | C1 #6
' B2 #23 | A2 #5 | C2 #1
' B3 #24
' B4 #25
' B5 #26
' B6 #27
' * // Display GND, VCC and N.C. [no connection] * //'
' GND 15,16,17,28
' VCC 2,7,8,9,10,11,14,18
' N.C. 12