Re: sehr langsamer Zähler Kategorie: Programmierung Basic (von Jörg der Tüftler - 2.08.2006 7:15) | ||
Als Antwort auf Re: sehr langsamer Zähler von PeterS - 16.07.2006 22:46 | ||
| ||
'----- LED HELLIGKEIT ----- #define BRIGHT0 &H07 #define BRIGHT1 &H17 #define BRIGHT2 &H27 #define BRIGHT3 &H37 #define BRIGHT4 &H47 #define BRIGHT5 &H57 #define BRIGHT6 &H67 #define BRIGHT7 &H77 '-------------------------- '---- SYSTEM MEMORY ------- '-------------------------- Dim TAUSENDER As Byte Dim HUNDERTER As Byte Dim ZEHNER As Byte Dim EINER As Byte Dim Port_C6 As Byte '----------------------------------------------------- ' 7 SEGMENT DECODER '----------------------------------------------------- Sub DECODE (CODE As Byte) As Byte Select Case CODE Case 0 CODE=&H3F Case 1 CODE=&H06 Case 2 CODE=&H5B Case 3 CODE=&H4F Case 4 CODE=&H66 Case 5 CODE=&H6D Case 6 CODE=&H7D Case 7 CODE=&H07 Case 8 CODE=&H7F Case 9 CODE=&H6F End Case Return CODE End Sub '------------------------------------------------------ '----------------------------------------------------- '-- IIC SEND BUFFER TO SAA1064 ---- '----------------------------------------------------- Sub SENDBUF(BRIGHT As Byte,DIGIT1 As Byte,DIGIT2 As Byte,DIGIT3 As Byte,DIGIT4 As Byte) I2C_Start() ' I2C Bus starten I2C_Write (&H76) ' Adresse des Bausteins I2C_Write (0) ' Startbit I2C_Write (BRIGHT) ' Controllbit I2C_Write (DIGIT1) ' erstes LED Segment I2C_Write (DIGIT2) ' zweites LED Segment I2C_Write (DIGIT3) ' drittes LED Segment I2C_Write (DIGIT4) ' viertes LED Segment I2C_Stop() ' I2C Stoppen AbsDelay(5) End Sub '---------------------------------------------------- ' SPLIT VALUE INTO DIGITS '---------------------------------------------------- Sub SPLIT_DIGITS(VALUE As Word) TAUSENDER=VALUE/1000 HUNDERTER=(VALUE-(TAUSENDER*1000))/100 ZEHNER=(VALUE-(TAUSENDER*1000)-(HUNDERTER*100))/10 EINER=VALUE-TAUSENDER*1000-HUNDERTER*100-ZEHNER*10 End Sub '------------------------------------------------------------------------------ ' Hauptprogramm ' Sub main() ' Variablendeklaration Dim COUNTER As Integer Dim Zeile(12) As Char I2C_Init(I2C_100kHz) ' I2C Bit Rate: 100 kHz LCD_Init() LCD_CursorPos(0) Zeile = "Wilhelm" ' LCD Cursor positionieren LCD_WriteText(Zeile) ' String ausgeben LCD_CursorPos(&H40) Zeile = "Schaber" ' LCD Cursor auf 2.Zeile positionieren LCD_WriteText(Zeile) ' String ausgeben 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 'III DEMO MESSAGES AND COUNTERS II 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII '---------- SHOW RUNNING COUNTER ------------------------ For COUNTER = 0 To 99 SPLIT_DIGITS(COUNTER) SENDBUF(BRIGHT1,DECODE(EINER),DECODE(ZEHNER),DECODE(HUNDERTER),DECODE(TAUSENDER)) Next '--------- FLASHING READY ------------------------------- Lab RDY Port_DataDirBit(1,0) Port_C6 = Port_ReadBit(1) SENDBUF(BRIGHT1,DECODE(EINER),DECODE(ZEHNER),DECODE(HUNDERTER),DECODE(TAUSENDER)) If Port_C6 = 0 Then COUNTER End If Goto RDY End Sub | ||
Antwort schreiben Antworten: |
Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum