Sari la conținut
ELFORUM - Forumul electronistilor

BASCOM


yo9hnf

Postări Recomandate

Merge acum...partial.Am instalat Bascom 1.11.9 si nu mai imi da eroarea. Am modificat configurarea LCDului si pinii pt butoane. Imi apare la inceput Hello ..avr project, dar cand trebuie sa imi afiseze ora ramane pe :Time =12:00:01 (12) PS : Eu nu am pe placa de dezvoltare (evb 4.3) rezistentele de pull-up de pe butoane.

Pinii SDA si SCL i-ai setat corect ptr placa ta de dezvoltare?
'configure the scl and sda pinsConfig Sda = Portd.7Config Scl = Portd.6
Link spre comentariu

Am gasit probabil varianta buna:

'================================================='* Www.yazdkit.com                               *'* Www.yazdkit.ir                                *'* Www.shop.yazdkit.com                          *'* This file download from www.yazdkit.com       *'* Email:[email protected]                        *'* Author=m-dashti                               *'================================================$regfile = "m8def.dat"$crystal = 1000000'------------------------  lcd -----------------------------------------------Config Lcd = 16 * 2Config Lcdpin = Pin , Rs = Pind.0 , E = Pind.1 , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5Cls'---------------------------  ds 1307 -----------------------------------------$lib "ds1307clock.lib"'configure the scl and sda pinsConfig Sda = Portd.7Config Scl = Portd.6'address of ds1307Const Ds1307w = &HD0                                        ' Addresses of Ds1307 clockConst Ds1307r = &HD1'------------------------------ key --------------------------------------------Config Pinc.1 = InputConfig Pinc.2 = InputConfig Pinc.3 = InputConfig Pinc.4 = Input'------------------------------------------------------------------------------Config Debounce = 30Dim A As Byte , B As Byte , Data1 As Byte , C As ByteDim Seco As Byte , Mine As Byte , Hour As Byte'----------------------------------------------------------------------------Cursor OffI2cstart                                            ' Generate start code        I2cwbyte Ds1307w                                    ' send address        I2cwbyte 0                                          ' start address in 1307        I2cstart                                            ' Generate start code        I2cwbyte Ds1307r                                    ' send address        I2crbyte Seco , Ack                                 'sec        I2crbyte Mine , Ack                                 ' MINUTES        I2crbyte Hour , Nack                                ' Hours        I2cstop        Gosub Seco'-----------------------------ClsLocate 1 , 6Lcd "Hello"Locate 2 , 1Lcd "WWW.Yazdkit.com"Wait 2For A = 1 To 15 Shiftlcd LeftWaitms 300NextCls'-------------------------------------------------------------------------------Main:Do         Gosub Ds1307         Gosub 24_12         Gosub ChekkeyLoop'-------------------------------------------------------------------------------Ds1307:        I2cstart                                            ' Generate start code        I2cwbyte Ds1307w                                    ' send address        I2cwbyte 0                                          ' start address in 1307        I2cstart                                            ' Generate start code        I2cwbyte Ds1307r                                    ' send address        I2crbyte Seco , Ack                                 'sec        I2crbyte Mine , Ack                                 ' MINUTES        I2crbyte Hour , Nack                                ' Hours        I2cstop        Seco = Makedec(seco) : Mine = Makedec(mine) : Hour = Makedec(hour)        If Seco > 59 Then Seco = 0        If Mine > 59 Then Mine = 0        If Hour > 23 Then        Hour = 0        Gosub Seco        End IfReturn'------------------------------------------------------------------------------- 24_12: If Pinc.4 = 1 Then Gosub Disply_24 If Pinc.4 = 0 Then Gosub Disply_12 Return'-------------------------------------------------------------------------------Disply_24:         Locate 1 , 1         Lcd "Time = " ; Hour ; ":" ; Mine ; ":" ; Seco ; "      "         Locate 2 , 6         Lcd "(24)"Return'-------------------------------------------------------------------------------Disply_12:         If Hour = 0 Then Hour = 12         If Hour > 12 Then Hour = Hour - 12         Locate 1 , 1         Lcd "Time = " ; Hour ; ":" ; Mine ; ":" ; Seco ; "      "         Locate 2 , 6         Lcd "(12)"Return'-------------------------------------------------------------------------------Chekkey:         Debounce Pinc.1 , 0 , Seco , Sub         Debounce Pinc.2 , 0 , Mine , Sub         Debounce Pinc.3 , 0 , Hour , SubReturn'---------------------------------------------Seco:         Incr Seco         If Seco > 59 Then Seco = 0         Seco = Makebcd(seco)         I2cstart                                           ' Generate start code         I2cwbyte Ds1307w                                   ' send address         I2cwbyte 0                                         ' starting address in 1307         I2cwbyte Seco         I2cstopReturn'-------------------------------------Mine:         Incr Mine         If Mine > 59 Then Mine = 0         Mine = Makebcd(mine)         I2cstart                                           ' Generate start code         I2cwbyte Ds1307w                                   ' send address         I2cwbyte 1                                         ' starting address in 1307         I2cwbyte Mine         I2cstopReturn'-------------------------------------Hour:         Incr Hour         If Hour > 23 Then Hour = 0         Hour = Makebcd(hour)         I2cstart                                           ' Generate start code         I2cwbyte Ds1307w                                   ' send address         I2cwbyte 2                                         ' starting address in 1307         I2cwbyte Hour         I2cstopReturn'-------------------------------------End
Link spre comentariu

Da, codurile sunt indentice. Rezultatul este identic.- I2C le-am pus pe Pinc.1 si Pinc.0-butoanele le-am pus ca in schema, pe ADC, adica Pina.1, pina.2 etc Folosesc atmega32 cu Q=16MHz

Link spre comentariu

Da, codurile sunt indentice. Rezultatul este identic.- I2C le-am pus pe Pinc.1 si Pinc.0-butoanele le-am pus ca in schema, pe ADC, adica Pina.1, pina.2 etc Folosesc atmega32 cu Q=16MHz

In program Dezactiveaza ADC, defineste porturile I2C asa cum ai scris mai sus si foloseste comenzile : I2CSEND , I2CRECEIVE.Daca nici asa nu merge, nu mai am idei.Dar ai verificat totusi ca uC comunica cu DS1307? Nu ai dat raspuns la aeasta intrebare!
Link spre comentariu

vreau sa folosesc 2 cipuri i2c tda7318 tea5767

codu de la danzap pt control tda + codu meu pt tea 5767 am probleme cu schimarea postului radio

selectarea postului se face cu select case

o prima problema era pentru select case ramanea selectat un singur caz asta am rezolvat-o dar tot nu merge am testat doar pucata de cod respectiv fara functiile tda7318 si merge fara probleme am mai incercat direct cand apas pe un buton fara selectare cazuri nici aasa nu am avut succes

 

If Pind.2 = 0 ThenWaitms 3ClsUpperlineLcd "Radio"Freq = 102.8Set Portb.4Set Portb.2Call RadioEnd If

exemplu select case

 

Sub Radio:Select Case HCase 0 : Decr C         If C < 1 Then C = 1Case 1 : Incr C         If C > 4 Then C = 4End SelectSelect Case CCase 1Station = 1LowerlineLcd "Pro FM"Case 2Station = 2LowerlineLcd "magic fm"Select Case StationCase 1Set Portb.4Set Portb.2Freq = 102.8Waitms 3station = 5   Case 2LowerlineSet Portb.4Set Portb.2Freq = 92.1Waitms 3Station = 5   Case 3LowerlineLcd "    Magic FM    "Set Portb.4Set Portb.2Freq = 90.8Waitms 10Station = 5   Case 4LowerlineLcd "  Europa FM    "Set Portb.4Set Portb.2Freq = 106.7Waitms 10Station = 5End SelectPll = Freq * 1000Pll = Pll + FgPll = Pll * 4Pll = Pll / FrefFset = Int(pll)1st = High(fset)Reset 1st.7                                                 'not muteReset 1st.6                                                 'not search2nd = Low(fset)3rd = &B000100004st = &B000100105th = &B00000000I2cstart                                                    'adresa icI2cwbyte &HC0                                               'adresa icI2cwbyte 1stI2cwbyte 2ndI2cwbyte 3rdI2cwbyte 4stI2cwbyte 5thReset Portb.4Reset Portb.2Waitms 30I2cstopW = 0Timer1 = WEnd Sub

aici e tot codu

 

'-------------------------------------------------------------------------------'  Controler pentru  TDA7318'  versiune - 13.0      (c)danzup'-------------------------------------------------------------------------------$regfile = "m8515.dat"                                      'register file for ATmega8515$crystal = 8000000                                          '8MHz crystalConfig Lcdbus = 4Config Lcd = 16 * 2Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0Ddrd = &B11000000                                           ' PD6...PD7 are output, PD0...PD5 are inputPortd = &B00111111                                          ' PD0...PD5 pull-up resistor enableDdrb = &B11111111Set Portb.0Config Scl = Porta.1Config Sda = Porta.0Config I2cdelay = 10Config Rc5 = Pind.3                                         'pin where is conected ir senzorConst Radioic = &HC0I2cinitConfig Timer1 = Timer , Prescale = 1024Stop Timer1Start Timer1Set Portd.7                                                 'LCD backlight onSet Portd.6                                                 'power relayDim Address As Byte , Command As Byte                       'RC5 ir variableDim Menu As Bit                                             'first buttonDim Plus As Bit                                             'second buttonDim Minus As Bit                                            'third buttonDim Onoff As Bit                                            'four buttonDim W As WordDim A As ByteDim B As ByteDim C As ByteDim Pwr As BitDim E As ByteDim D As SingleDim F As ByteDim G As ByteDim Mask As ByteA = 7B = 1C = 1E = 30G = 30Pwr = 0Dim H As BitDim Tont As ByteDim Tonb As ByteDim Vol_me As ByteDim Inp_ut As ByteDim Att_lr As ByteDim Att_rr As ByteDim Att_lf As ByteDim Att_rf As ByteDim Bas_ss As ByteDim Tre_le As ByteDim Gain As ByteDim Gain_v As ByteDim Gain_d As SingleDim Gain_d1 As SingleDim Gain_d2 As SingleDim Gain_d3 As SingleDim Gain_d4 As SingleDim Temp As Byte'----------------------------------------------------'radioDeclare Sub RadioDim Station As ByteDim Pll As SingleDim Fset As WordDim Freq As Single                                          ' set freqDim 1st As ByteDim 2nd As ByteDim 3rd As ByteDim 4st As ByteDim 5th As ByteConst Fref = 32.768                                         ' cristal freq radio moduleConst Fg = 250Gain_d1 = 0Gain_d2 = 0Gain_d3 = 0Gain_d4 = 0Tont = 8Tonb = 8Gain_v = &B00011000Gain_d = 0Vol_me = &B00100000                                         'default volum -40dBInp_ut = &B01010000                                         'default intrarea stereo1 ;gain 0db   ( 88 )Att_lr = &B11000000                                         'default atenuare lr 0dB   ( 192 )Att_rr = &B11100000                                         'default atenuare rr 0dB   ( 224 )Att_lf = &B10000000                                         'default atenuare lr 0dB   ( 128 )Att_rf = &B10100000                                         'default atenuare rr 0dB   ( 160 )Bas_ss = &B01100111                                         'default 0dB ( 103 )Tre_le = &B01110111                                         'default 0dB ( 119 )'-----------------------------------------------------------------Dim Char_pos As ByteDim Bar_len As WordDim T1 As SingleConst Char_max = 16                                         'number of LCD characters (one row)Deflcdchar 5 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 32        ' barCls                                                         'Cursor OffDeclare Sub MmenuDeclare Sub MplusDeclare Sub MminusDeclare Sub MonoffDeclare Sub ToneshDeclare Sub TonesjDeclare Sub Pwr_onDeclare Sub Pwr_offDeclare Sub Inpt_gainDeclare Sub DisplDeclare Sub Inpt_chgn'Declare Sub MuteClsLcd "Script Amplituner"Locate 2 , 1Lcd "2 x 80W"Wait 2Cls'--incarc toata cofiguratia default in TDA----I2csend &H88 , Vol_meI2csend &H88 , Att_rfI2csend &H88 , Att_lfI2csend &H88 , Att_rrI2csend &H88 , Att_lrI2csend &H88 , Tre_leI2csend &H88 , Bas_ssI2csend &H88 , Inp_ut'---------------------------------------------Call Pwr_offEnable InterruptsReset Portd.7Reset Portd.6DoIf Pwr = 1 Then W = Timer1  If W => 59990 Then   A = 7   Call Mmenu  End IfGetrc5(address , Command)                                   'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End IfSelect Case Command'---- this codes are for my remote , change code to your suit ! ----------------   Case 32 : Call Mmenu                                     'remote command code for CH up   Case 161 : Call Mmenu   Case 33 : Call Mmenu                                     'remote command code for CH down   Case 160 : Call Mmenu   Case 17 : Call Mplus                                     'remote command code for Vol +   Case 145 : Call Mplus   Case 16 : Call Mminus                                    'remote command code for Vol -   Case 144 : Call Mminus   Case 12 : Call Monoff                                    'remote command code for On/Off   Case 140 : Call Monoff   Case 48 : Call Radio   End Select Menu = Pind.4                                              ' Plus = Pind.1                                              ' Minus = Pind.0                                             ' Onoff = Pind.5                                             ' If Menu = 0 Then                                           'now we read the push buttons for command      Waitms 5      Call Mmenu                                            'button for menu presed End If If Plus = 0 Then      Waitms 5      Call Mplus                                            'button Plus presed End If If Minus = 0 Then      Waitms 5      Call Mminus                                           'button Minus presed End If If Onoff = 0 Then      Waitms 5      Call Monoff                                           'button On/off presed End IfEnd IfIf Pwr = 0 Then Getrc5(address , Command)                                  'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End If  Select Case Command '---- this codes are for my remote , change code to your suit ! ----------------  Case 12 : Call Monoff                                     'remote command code for On/Off  Case 140 : Call Monoff  End Select  Onoff = Pind.5     If Onoff = 0 Then      Waitms 10      Call Monoff                                           'button On/off presed     End IfEnd IfLoopEnd'-----------Mmenu-----------------Sub Mmenu:A = A + 1Set Portd.7                                                 'backlight onIf A > 6 Then   A = 0   End IfIf A = 0 Then   Home Upper   Lcd "-    Volume    +"   T1 = Vol_me / 3.9375   Bar_len = 16 - Int(t1)   Waitms 180End IfIf A = 1 Then   Home Upper   Lcd " Select Input   "   Home Lower   Lcd "     Input  " ; C ; "   "   Waitms 180End IfIf A = 2 Then   Cls   Home Upper   Lcd "Radio Station"   Lowerline   Lcd "     Chanel  " ; C ; "  "   Waitms 180   End IfIf A = 3 Then   Home Upper   Lcd "  Right Channel "   D = E / 3.75   Bar_len = Int(d )   Waitms 180End If   Waitms 180   If A = 4 Then   Home Upper   Lcd "  Left Channel  "   D = E / 3.75   Bar_len = Int(d )   Waitms 180End If   Waitms 180If A = 5 Then   Home Upper   Lcd "-    Bass      +"   Bar_len = Tonb   Waitms 180End IfIf A = 6 Then   Home Upper   Lcd "-    Treble    +"   Bar_len = Tont   Waitms 180End IfCall DisplEnd Sub'-----------Mplus-----------------Sub Mplus:'-------regelz volumul-----------------------If A = 0 Then  If Vol_me < 63 Then  Incr Vol_me  T1 = Vol_me / 3.9375  Bar_len = 16 - Int(t1)  I2csend &H88 , Vol_me  End If  Call DisplEnd If'------------Right Front --------------If A = 3 ThenIncr Att_rf If Att_rf > 190 Then Att_rf = 190 End If  If E > 1 Then     Decr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_rf  Call Displ  Waitms 50End If'--------------Left Front--------------If A = 4 ThenIncr Att_lf If Att_lf > 190 Then Att_lf = 190 End If  If E > 1 Then     Decr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_lf  Call Displ  Waitms 50End If'------------reglez Bass--------------------------If A = 5 Then  H = 1  Call Tonesh  Bar_len = Tonb  Call DisplEnd If'------------reglez Treble-----------------------------If A = 6 Then  H = 1  Call Tonesj  Bar_len = Tont  Call DisplEnd If'---------reglez Gain Input--------------------------'---------reglez radio--------------------------If A = 2 ThenH = 1Call RadioWaitms 180End If'---------modific intrarea selectata-----------If A = 1 Then  H = 0  Call Inpt_chgn  Waitms 180End IfEnd Sub'-----------Mminus-----------------Sub Mminus:'------------reglez volum------------------If A = 0 Then  If Vol_me > 0 Then  Decr Vol_me  T1 = Vol_me / 3.9375  Bar_len = 16 - Int(t1)  I2csend &H88 , Vol_me  End If  Call DisplEnd If'---------reglez radio--------------------------If A = 2 ThenH = 0Call RadioWaitms 180End If'-------------Right front--------------If A = 3 ThenDecr Att_rfIf Att_rf < 160 ThenAtt_rf = 160End If  If E < 60 Then     Incr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_rf  Call Displ  Waitms 50End If'-------------left front---------------------If A = 4 ThenDecr Att_lfIf Att_lf < 160 ThenAtt_lf = 160End If  If E < 60 Then     Incr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_lf  Call Displ  Waitms 50End If'---------------reglez Bass----------------If A = 5 Then  H = 0  Call Tonesh  Bar_len = Tonb  Call DisplEnd If'------------reglez Treble------------------If A = 6 Then  H = 0  Call Tonesj  Bar_len = Tont  Call DisplEnd If'-----------reglez Gain Input---------------'---------modific intrarea selectata-----------If A = 1 Then  H = 1  Call Inpt_chgn  Waitms 180End IfEnd Sub'-----------Monoff-----------------Sub Monoff:Pwr = Not Pwr If Pwr = 1 Then Call Pwr_on Else Call Pwr_off End IfEnd Sub'------------Pwr_on-------------------------Sub Pwr_on:Display OnDecr AI2csend &H88 , Vol_meI2csend &H88 , Inp_utI2csend &H88 , Att_rfI2csend &H88 , Att_lfI2csend &H88 , Att_rrI2csend &H88 , Att_lrSet Portd.6                                                 'power relay onSet Portd.7                                                 'backlight onWaitms 500Call MmenuW = 0Timer1 = WEnd Sub'------------Pwr_off-------------------------Sub Pwr_off:Display OffI2csend &H88 , &B11111111I2csend &H88 , &B10011111I2csend &H88 , &B10111111I2csend &H88 , &B11011111Reset Portd.6                                               'power relay offReset Portd.7                                               'backlight offWaitms 500End Sub'------------Tonesh----------------------Sub Tonesh:Select Case HCase 1 : Decr Tonb         If Tonb < 1 Then Tonb = 1Case 0 : Incr Tonb         If Tonb > 15 Then Tonb = 15End SelectSelect Case Tonb   Case 1 : Bas_ss = 96   Case 2 : Bas_ss = 97   Case 3 : Bas_ss = 98   Case 4 : Bas_ss = 99   Case 5 : Bas_ss = 100   Case 6 : Bas_ss = 101   Case 7 : Bas_ss = 102   Case 8 : Bas_ss = 103   Case 9 : Bas_ss = 110   Case 10 : Bas_ss = 109   Case 11 : Bas_ss = 108   Case 12 : Bas_ss = 107   Case 13 : Bas_ss = 106   Case 14 : Bas_ss = 105   Case 15 : Bas_ss = 104End SelectI2csend &H88 , Bas_ssEnd Sub'------------Tonesj--------------Sub Tonesj:Select Case HCase 1 : Decr Tont         If Tont < 1 Then Tont = 1Case 0 : Incr Tont         If Tont > 15 Then Tont = 15End SelectSelect Case Tont   Case 1 : Tre_le = 112   Case 2 : Tre_le = 113   Case 3 : Tre_le = 114   Case 4 : Tre_le = 115   Case 5 : Tre_le = 116   Case 6 : Tre_le = 117   Case 7 : Tre_le = 118   Case 8 : Tre_le = 119   Case 9 : Tre_le = 126   Case 10 : Tre_le = 125   Case 11 : Tre_le = 124   Case 12 : Tre_le = 123   Case 13 : Tre_le = 122   Case 14 : Tre_le = 121   Case 15 : Tre_le = 120End SelectI2csend &H88 , Tre_leEnd Sub'----------Inpt_chgn-------------Sub Inpt_chgn:Select Case HCase 0 : Decr C         If C < 1 Then C = 1Case 1 : Incr C         If C > 4 Then C = 4End SelectSelect Case C   Case 1 : Mask = &B00000000   Lowerline   Lcd "      DVD       "   Case 2 : Mask = &B00000001   Lowerline   Lcd "      PC       "   Case 3 : Mask = &B00000010   Lowerline   Lcd "      Mp3       "   Case 4 : Mask = &B00000011   Lowerline   Lcd "     Radio      "End SelectTemp = Inp_ut And &B11111100Inp_ut = Temp Or MaskI2csend &H88 , Inp_utW = 0Timer1 = WEnd Sub'---------rado-----------------Sub Radio:Select Case HCase 0 : Decr C         If C < 1 Then C = 1Case 1 : Incr C         If C > 4 Then C = 4End SelectSelect Case CCase 1Station = 1LowerlineLcd "Pro FM"Case 2Station = 2LowerlineLcd "magic fm"Select Case StationCase 1Set Portb.4Set Portb.2Freq = 102.8Waitms 3station = 5   Case 2LowerlineSet Portb.4Set Portb.2Freq = 92.1Waitms 3Station = 5   Case 3LowerlineLcd "    Magic FM    "Set Portb.4Set Portb.2Freq = 90.8Waitms 10Station = 5   Case 4LowerlineLcd "  Europa FM    "Set Portb.4Set Portb.2Freq = 106.7Waitms 10Station = 5End SelectPll = Freq * 1000Pll = Pll + FgPll = Pll * 4Pll = Pll / FrefFset = Int(pll)1st = High(fset)Reset 1st.7                                                 'not muteReset 1st.6                                                 'not search2nd = Low(fset)3rd = &B000100004st = &B000100105th = &B00000000I2cstart                                                    'adresa icI2cwbyte &HC0                                               'adresa icI2cwbyte 1stI2cwbyte 2ndI2cwbyte 3rdI2cwbyte 4stI2cwbyte 5thReset Portb.4Reset Portb.2Waitms 30I2cstopW = 0Timer1 = WEnd Sub'----------Displ---------------Sub Displ:If A <> 1 Then  If A <> 2 Then   Locate 2 , 1                                             'set LCD first character position   For Char_pos = 1 To Char_max                             'number of characters    If Char_pos <= Bar_len Then                             'print one bar      Lcd Chr(5)                                            'print special char                                         '    Else      Lcd Chr(32)                                           'print spaces to fill row    End If   Next  End IfEnd IfW = 0Timer1 = WEnd Sub

cod simplu fara tda care merge

'default template for script devboard atmega 16'_____________________________________________'setup$regfile = "m8515.dat"                                      'register file for ATmega8515$crystal = 8000000                                          '8MHz crystalConfig Lcdbus = 4Config Lcd = 16 * 2Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0Ddrd = &B11000000                                           ' PD6...PD7 are output, PD0...PD5 are inputPortd = &B00111111                                          ' PD0...PD5 pull-up resistor enableDdrb = &B11111111Config Sda = Porta.1Config Scl = Porta.0Config I2cdelay = 10Config Rc5 = Pind.3'Porta.4 = 1                                                 ' enable pull up resistor buton 1'Porta.5 = 1                                                 ' enable pull up resistor buton 2'Porta.6 = 1                                                 ' enable pull up resistor buton 3'Porta.7 = 1                                                 ' enable pull up resistor buton 4'_____________________________________________'configDim Address As Byte , Command As Byte                       'RC5 ir variableDim Pll As SingleDim Fset As WordDim Freq As Single                                          ' set freqDim 1st As ByteDim 2nd As ByteDim 3rd As ByteDim 4st As ByteDim 5th As ByteConst Fref = 32.768                                         ' cristal freq radio moduleConst Fg = 250I2cinitEnable InterruptsDeclare Sub RadioDeclare Sub DisplDeclare Sub MenuDim B As SingleDim Char_pos As ByteDim Bar_len As WordConst Char_max = 16                                         'number of LCD characters (one row)Dim Station As ByteDeflcdchar 5 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 32        ' barDim H As ByteDim C As ByteSet Portd.7Cursor Off NoblinkClsLcd "Script Devboard "Locate 2 , 1Lcd " Core Atmega 16 "Waitms 180ClsLcd "  Radio tunner  "LowerlineLcd "Tea 5767 i2c cip"Waitms 5ClsLcd "    Loading     "For B = 1 To 30Bar_len = Int(b )Waitms 50Call DisplNextClsLcd " Select Channel "LowerlineLcd " >B1 B2 B3 B4< "'_____________________________________________'main programDoGetrc5(address , Command)                                   'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End If  If Pind.0 = 0 ThenWaitms 3C = 1End IfIf Pind.1 = 0 ThenWaitms 3C = 2End IfIf Pind.4 = 0 ThenWaitms 3C = 3End IfIf Pind.5 = 0 ThenWaitms 3C = 4End IfCall RadioLoopSub Radio:Select Case CCase 1Station = 1LowerlineLcd "Pro FM"Case 2Station = 2LowerlineLcd "vibe fm"End SelectSelect Case StationCase 1Set Portb.4Set Portb.2Freq = 102.8Waitms 10station = 5   Case 2LowerlineSet Portb.4Set Portb.2Freq = 92.1Waitms 10Station = 5End SelectPll = Freq * 1000Pll = Pll + FgPll = Pll * 4Pll = Pll / FrefFset = Int(pll)1st = High(fset)Reset 1st.7                                                 'not muteReset 1st.6                                                 'not search2nd = Low(fset)3rd = &B000100004st = &B000100105th = &B00000000I2cstartI2cwbyte &HC0                                               'adresa icI2cwbyte 1stI2cwbyte 2ndI2cwbyte 3rdI2cwbyte 4stI2cwbyte 5thI2cstopReset Portb.4End SubSub Displ:If B <> 1 Then  If B <> 2 Then   Locate 2 , 1                                             'set LCD first character position   For Char_pos = 1 To Char_max                             'number of characters    If Char_pos <= Bar_len Then                             'print one bar      Lcd Chr(5)                                            'print special char                                         '    Else      Lcd Chr(32)                                           'print spaces to fill row    End If   Next  End IfEnd IfEnd SubEnd

normal codu asta ar trbui sa meraga impreuna cu cel pt tda

i2csend foloseste tda iar tea5767 foloseste i2cwrite asa am gasit o bucata de cod pe net

sa fie asta problema , am incercat cu i2csend da nu merge deloc in varianta simpla

trebuie cumva modificat sa mearga cu i2csend , se ofera careva sa ma ajute

Link spre comentariu

Incearca asa, poate merge.

'-------------------------------------------------------------------------------'  Controler pentru  TDA7318'  versiune - 13.0      (c)danzup'-------------------------------------------------------------------------------$regfile = "m8515.dat"                                      'register file for ATmega8515$crystal = 8000000                                          '8MHz crystalConfig Lcdbus = 4Config Lcd = 16 * 2Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0Ddrd = &B11000000                                           ' PD6...PD7 are output, PD0...PD5 are inputPortd = &B00111111                                          ' PD0...PD5 pull-up resistor enableDdrb = &B11111111Set Portb.0Config Scl = Porta.1Config Sda = Porta.0Config I2cdelay = 10Config Rc5 = Pind.3                                         'pin where is conected ir senzorConst Radioic = &HC0I2cinitConfig Timer1 = Timer , Prescale = 1024Stop Timer1Start Timer1Set Portd.7                                                 'LCD backlight onSet Portd.6                                                 'power relayDim Address As Byte , Command As Byte                       'RC5 ir variableDim Menu As Bit                                             'first buttonDim Plus As Bit                                             'second buttonDim Minus As Bit                                            'third buttonDim Onoff As Bit                                            'four buttonDim W As WordDim A As ByteDim B As ByteDim C As ByteDim Pwr As BitDim E As ByteDim D As SingleDim F As ByteDim G As ByteDim Mask As ByteA = 7B = 1C = 1E = 30G = 30Pwr = 0Dim H As BitDim Tont As ByteDim Tonb As ByteDim Vol_me As ByteDim Inp_ut As ByteDim Att_lr As ByteDim Att_rr As ByteDim Att_lf As ByteDim Att_rf As ByteDim Bas_ss As ByteDim Tre_le As ByteDim Gain As ByteDim Gain_v As ByteDim Gain_d As SingleDim Gain_d1 As SingleDim Gain_d2 As SingleDim Gain_d3 As SingleDim Gain_d4 As SingleDim Temp As Byte'----------------------------------------------------'radioDeclare Sub RadioDim Station As ByteDim Pll As SingleDim Fset As WordDim Freq As Single                                          ' set freqDim 1st As ByteDim 2nd As ByteDim 3rd As ByteDim 4st As ByteDim 5th As ByteConst Fref = 32.768                                         ' cristal freq radio moduleConst Fg = 250Gain_d1 = 0Gain_d2 = 0Gain_d3 = 0Gain_d4 = 0Tont = 8Tonb = 8Gain_v = &B00011000Gain_d = 0Vol_me = &B00100000                                         'default volum -40dBInp_ut = &B01010000                                         'default intrarea stereo1 ;gain 0db   ( 88 )Att_lr = &B11000000                                         'default atenuare lr 0dB   ( 192 )Att_rr = &B11100000                                         'default atenuare rr 0dB   ( 224 )Att_lf = &B10000000                                         'default atenuare lr 0dB   ( 128 )Att_rf = &B10100000                                         'default atenuare rr 0dB   ( 160 )Bas_ss = &B01100111                                         'default 0dB ( 103 )Tre_le = &B01110111                                         'default 0dB ( 119 )'-----------------------------------------------------------------Dim Char_pos As ByteDim Bar_len As WordDim T1 As SingleConst Char_max = 16                                         'number of LCD characters (one row)Deflcdchar 5 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 32        ' barCls                                                         'Cursor OffDeclare Sub MmenuDeclare Sub MplusDeclare Sub MminusDeclare Sub MonoffDeclare Sub ToneshDeclare Sub TonesjDeclare Sub Pwr_onDeclare Sub Pwr_offDeclare Sub Inpt_gainDeclare Sub DisplDeclare Sub Inpt_chgn'Declare Sub MuteClsLcd "Script Amplituner"Locate 2 , 1Lcd "2 x 80W"Wait 2Cls'--incarc toata cofiguratia default in TDA----I2csend &H88 , Vol_meI2csend &H88 , Att_rfI2csend &H88 , Att_lfI2csend &H88 , Att_rrI2csend &H88 , Att_lrI2csend &H88 , Tre_leI2csend &H88 , Bas_ssI2csend &H88 , Inp_ut'---------------------------------------------Call Pwr_offEnable InterruptsReset Portd.7Reset Portd.6Do   If Pwr = 1 Then      W = Timer1      If W => 59990 Then         A = 7         Call Mmenu      End If      Getrc5(address , Command)                             'read if we have remote ir command      If Address = 10 Then         Command = Command And &B01111111      End If      Select Case Command'---- this codes are for my remote , change code to your suit ! ----------------         Case 32 : Call Mmenu                               'remote command code for CH up         Case 161 : Call Mmenu         Case 33 : Call Mmenu                               'remote command code for CH down         Case 160 : Call Mmenu         Case 17 : Call Mplus                               'remote command code for Vol +         Case 145 : Call Mplus         Case 16 : Call Mminus                              'remote command code for Vol -         Case 144 : Call Mminus         Case 12 : Call Monoff                              'remote command code for On/Off         Case 140 : Call Monoff         Case 48 : Call Radio      End Select      Menu = Pind.4                                         '      Plus = Pind.1                                         '      Minus = Pind.0                                        '      Onoff = Pind.5                                        '      If Menu = 0 Then                                      'now we read the push buttons for command         Waitms 5         Call Mmenu                                         'button for menu presed      End If      If Plus = 0 Then         Waitms 5         Call Mplus                                         'button Plus presed      End If      If Minus = 0 Then         Waitms 5         Call Mminus                                        'button Minus presed      End If      If Onoff = 0 Then         Waitms 5         Call Monoff                                        'button On/off presed      End If   End If   If Pwr = 0 Then      Getrc5(address , Command)                             'read if we have remote ir command      If Address = 10 Then         Command = Command And &B01111111      End If      Select Case Command'---- this codes are for my remote , change code to your suit ! ----------------         Case 12 : Call Monoff                              'remote command code for On/Off         Case 140 : Call Monoff      End Select      Onoff = Pind.5      If Onoff = 0 Then         Waitms 10         Call Monoff                                        'button On/off presed      End If   End IfLoopEnd'-----------Mmenu-----------------Sub Mmenu:   A = A + 1   Set Portd.7                                              'backlight on   If A > 6 Then      A = 0      End If   If A = 0 Then      Home Upper      Lcd "-    Volume    +"      T1 = Vol_me / 3.9375      Bar_len = 16 - Int(t1)      Waitms 180   End If   If A = 1 Then      Home Upper      Lcd " Select Input   "      Home Lower      Lcd "     Input  " ; C ; "   "      Waitms 180   End If   If A = 2 Then      Cls      Home Upper      Lcd "Radio Station"      Lowerline      Lcd "     Chanel  " ; C ; "  "      Waitms 180   End If   If A = 3 Then      Home Upper      Lcd "  Right Channel "      D = E / 3.75      Bar_len = Int(d )      Waitms 180   End If   Waitms 180   If A = 4 Then      Home Upper      Lcd "  Left Channel  "      D = E / 3.75      Bar_len = Int(d )      Waitms 180   End If   Waitms 180   If A = 5 Then      Home Upper      Lcd "-    Bass      +"      Bar_len = Tonb      Waitms 180   End If   If A = 6 Then      Home Upper      Lcd "-    Treble    +"      Bar_len = Tont      Waitms 180   End If   Call DisplEnd Sub'-----------Mplus-----------------Sub Mplus:'-------regelz volumul-----------------------   If A = 0 Then      If Vol_me < 63 Then         Incr Vol_me         T1 = Vol_me / 3.9375         Bar_len = 16 - Int(t1)         I2csend &H88 , Vol_me      End If      Call Displ   End If'---------modific intrarea selectata-----------   If A = 1 Then      H = 0      Call Inpt_chgn      Waitms 180   End If'---------reglez radio--------------------------   If A = 2 Then      H = 1      Call Radio      Waitms 180   End If'------------Right Front --------------   If A = 3 Then      Incr Att_rf      If Att_rf > 190 Then         Att_rf = 190      End If      If E > 1 Then         Decr E      End If      D = E / 3.75      Bar_len = Int(d )      I2csend &H88 , Att_rf      Call Displ      Waitms 50   End If'--------------Left Front--------------   If A = 4 Then      Incr Att_lf      If Att_lf > 190 Then      Att_lf = 190   End If      If E > 1 Then         Decr E      End If      D = E / 3.75      Bar_len = Int(d )      I2csend &H88 , Att_lf      Call Displ      Waitms 50   End If'------------reglez Bass--------------------------   If A = 5 Then      H = 1      Call Tonesh      Bar_len = Tonb      Call Displ   End If'------------reglez Treble-----------------------------   If A = 6 Then      H = 1      Call Tonesj      Bar_len = Tont      Call Displ   End If'---------reglez Gain Input--------------------------End Sub'-----------Mminus-----------------Sub Mminus:'------------reglez volum------------------   If A = 0 Then      If Vol_me > 0 Then         Decr Vol_me         T1 = Vol_me / 3.9375         Bar_len = 16 - Int(t1)         I2csend &H88 , Vol_me      End If      Call Displ   End If'---------modific intrarea selectata-----------   If A = 1 Then      H = 1      Call Inpt_chgn      Waitms 180   End If'---------reglez radio--------------------------   If A = 2 Then      H = 0      Call Radio      Waitms 180   End If'-------------Right front--------------   If A = 3 Then      Decr Att_rf      If Att_rf < 160 Then         Att_rf = 160      End If      If E < 60 Then         Incr E      End If      D = E / 3.75      Bar_len = Int(d )      I2csend &H88 , Att_rf      Call Displ      Waitms 50   End If'-------------left front---------------------   If A = 4 Then      Decr Att_lf      If Att_lf < 160 Then         Att_lf = 160      End If      If E < 60 Then         Incr E      End If      D = E / 3.75      Bar_len = Int(d )      I2csend &H88 , Att_lf      Call Displ      Waitms 50   End If'---------------reglez Bass----------------   If A = 5 Then      H = 0      Call Tonesh      Bar_len = Tonb      Call Displ   End If'------------reglez Treble------------------   If A = 6 Then      H = 0      Call Tonesj      Bar_len = Tont      Call Displ   End If'-----------reglez Gain Input---------------End Sub'-----------Monoff-----------------Sub Monoff:   Pwr = Not Pwr   If Pwr = 1 Then      Call Pwr_on   Else      Call Pwr_off   End IfEnd Sub'------------Pwr_on-------------------------Sub Pwr_on:   Display On   Decr A   I2csend &H88 , Vol_me   I2csend &H88 , Inp_ut   I2csend &H88 , Att_rf   I2csend &H88 , Att_lf   I2csend &H88 , Att_rr   I2csend &H88 , Att_lr   Set Portd.6                                              'power relay on   Set Portd.7                                              'backlight on   Waitms 500   Call Mmenu   W = 0   Timer1 = WEnd Sub'------------Pwr_off-------------------------Sub Pwr_off:   Display Off   I2csend &H88 , &B11111111   I2csend &H88 , &B10011111   I2csend &H88 , &B10111111   I2csend &H88 , &B11011111   Reset Portd.6                                            'power relay off   Reset Portd.7                                            'backlight off   Waitms 500End Sub'------------Tonesh----------------------Sub Tonesh:   Select Case H      Case 1 :         Decr Tonb         If Tonb < 1 Then Tonb = 1      Case 0 :         Incr Tonb         If Tonb > 15 Then Tonb = 15   End Select   Select Case Tonb      Case 1 : Bas_ss = 96      Case 2 : Bas_ss = 97      Case 3 : Bas_ss = 98      Case 4 : Bas_ss = 99      Case 5 : Bas_ss = 100      Case 6 : Bas_ss = 101      Case 7 : Bas_ss = 102      Case 8 : Bas_ss = 103      Case 9 : Bas_ss = 110      Case 10 : Bas_ss = 109      Case 11 : Bas_ss = 108      Case 12 : Bas_ss = 107      Case 13 : Bas_ss = 106      Case 14 : Bas_ss = 105      Case 15 : Bas_ss = 104   End Select   I2csend &H88 , Bas_ssEnd Sub'------------Tonesj--------------Sub Tonesj:Select Case H   Case 1 : Decr Tont         If Tont < 1 Then Tont = 1   Case 0 : Incr Tont         If Tont > 15 Then Tont = 15   End Select   Select Case Tont      Case 1 : Tre_le = 112      Case 2 : Tre_le = 113      Case 3 : Tre_le = 114      Case 4 : Tre_le = 115      Case 5 : Tre_le = 116      Case 6 : Tre_le = 117      Case 7 : Tre_le = 118      Case 8 : Tre_le = 119      Case 9 : Tre_le = 126      Case 10 : Tre_le = 125      Case 11 : Tre_le = 124      Case 12 : Tre_le = 123      Case 13 : Tre_le = 122      Case 14 : Tre_le = 121      Case 15 : Tre_le = 120   End Select   I2csend &H88 , Tre_leEnd Sub'----------Inpt_chgn-------------Sub Inpt_chgn:   Select Case H      Case 0 :         Decr C         If C < 1 Then C = 1      Case 1 :         Incr C         If C > 4 Then C = 4   End Select   Select Case C      Case 1 :         Mask = &B00000000         Lowerline         Lcd "      DVD       "      Case 2 :         Mask = &B00000001         Lowerline         Lcd "      PC       "      Case 3 :         Mask = &B00000010         Lowerline         Lcd "      Mp3       "      Case 4 :         Mask = &B00000011         Lowerline         Lcd "     Radio      "   End Select   Temp = Inp_ut And &B11111100   Inp_ut = Temp Or Mask   I2csend &H88 , Inp_ut   W = 0   Timer1 = WEnd Sub'---------rado-----------------Sub Radio:   Select Case H      Case 0 : Decr C         If C < 1 Then C = 4                                'daca ajunge la capat sare de la inceput      Case 1 : Incr C         If C > 4 Then C = 1                                'daca ajunge la capat sare de la inceput   End Select   Select Case C      Case 1 :         Lowerline         Lcd "     Pro FM     "         Set Portb.4         Set Portb.2         Freq = 102.8         Waitms 10      Case 2 :         Lowerline         Lcd "    Magic FM    "         Set Portb.4         Set Portb.2         Freq = 92.1         Waitms 10      Case 3 :         Lowerline         Lcd "    Magic FM    "         Set Portb.4         Set Portb.2         Freq = 90.8         Waitms 10      Case 4 :         Lowerline         Lcd "  Europa FM    "         Set Portb.4         Set Portb.2         Freq = 106.7         Waitms 10   End Select   Pll = Freq * 1000   Pll = Pll + Fg   Pll = Pll * 4   Pll = Pll / Fref     Fset = Int(pll)   1st = High(fset)   Reset 1st.7                                              'not mute   Reset 1st.6                                              'not search   2nd = Low(fset)   3rd = &B00010000   4st = &B00010010   5th = &B00000000   I2cstart                                                 'adresa ic   I2cwbyte &HC0                                            'adresa ic   I2cwbyte 1st   I2cwbyte 2nd   I2cwbyte 3rd   I2cwbyte 4st   I2cwbyte 5th   Reset Portb.4   Reset Portb.2   Waitms 30   I2cstop   W = 0   Timer1 = WEnd Sub'----------Displ---------------Sub Displ:If A <> 1 Then  If A <> 2 Then   Locate 2 , 1                                             'set LCD first character position   For Char_pos = 1 To Char_max                             'number of characters    If Char_pos <= Bar_len Then                             'print one bar      Lcd Chr(5)                                            'print special char                                         '    Else      Lcd Chr(32)                                           'print spaces to fill row    End If   Next  End IfEnd IfW = 0Timer1 = WEnd Sub
Link spre comentariu

asa am facut prima data nu va merge

 

Case 3 :

Lowerline

Lcd " Magic FM "

Set Portb.4 Hi pentru scrie date cip radio , reset dupa cedatele au fost scrise

Set Portb.2 led de proba

Freq = 90.8

Waitms 10

 

portu va ramane hi cat timp C va fi 3

 

de asta eu am folosit c sa schimb station dupa sa il aduc pe c 5 adica C va fi 3 doar waitms 3

 

 

Select Case HCase 0 : Decr C         If C < 1 Then C = 1Case 1 : Incr C         If C > 4 Then C = 4End SelectSelect Case CCase 1Station = 1LowerlineLcd "Pro FM"Case 2Station = 2LowerlineLcd "magic fm"Select Case StationCase 1Set Portb.4Set Portb.2Freq = 102.8Waitms 3station = 5   Case 2LowerlineSet Portb.4Set Portb.2Freq = 92.1Waitms 3Station = 5

asa merge cu codu simplu fara tda cum ai aratat tu mai sus am incercat prima data fara succes , nici simplu nu merge ramane ledu aprins , am trimis si manual la apasarea unui buton freq = .. set port.. waitms 3 , in varianta simpa merge cu tda nu , ramane sa fie i2wbite care modificat i2csend teoretic ar merge

Link spre comentariu

Salut , nu am vazut nicaieri unde initializezi portul B , de ex :Config portb.4 =outputConfig portb.2= outputAi facut asta ?Apoi care dintre variante zici ca nu merge , ca sunt un pic confuz .Pune din nou sau spune care e varianta ca sa ma uit eu pe programul tau .

Link spre comentariu

varianta simpla cu tda 7318 unde am integrat in meniu si afisare pentru radio , merge cum e acm afiseaza radio , dupa am copiat in sub radio tot programu care merge pe direct , atentie pe direct merge doar cu command schimbarea posturilor , aici a fost putin pana mi-am dat eu seama command probabil se reseateaza dupa ceva ms asta in functiile bascomului eu asa am nimerit si asa a mers pana acm

'-------------------------------------------------------------------------------'  Controler pentru  TDA7318'  versiune - 13.0      (c)danzup'-------------------------------------------------------------------------------$regfile = "m8515.dat"                                      'register file for ATmega8515$crystal = 8000000                                          '8MHz crystalConfig Lcdbus = 4Config Lcd = 16 * 2Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0Ddrd = &B11000000                                           ' PD6...PD7 are output, PD0...PD5 are inputPortd = &B00111111                                          ' PD0...PD5 pull-up resistor enableDdrb = &B11111111 					    ' portb  = output Set Portb.0 						    ' set port.b 0 de proba am un led conectat Config Scl = Porta.1Config Sda = Porta.0Config I2cdelay = 10Config Rc5 = Pind.3                                         'pin where is conected ir senzorConst Radioic = &HC0I2cinitConfig Timer1 = Timer , Prescale = 1024Stop Timer1Start Timer1Set Portd.7                                                 'LCD backlight onSet Portd.6                                                 'power relayDim Address As Byte , Command As Byte                       'RC5 ir variableDim Menu As Bit                                             'first buttonDim Plus As Bit                                             'second buttonDim Minus As Bit                                            'third buttonDim Onoff As Bit                                            'four buttonDim W As WordDim A As ByteDim B As ByteDim C As ByteDim Pwr As BitDim E As ByteDim D As SingleDim F As ByteDim G As ByteDim Mask As ByteA = 7B = 1C = 1E = 30G = 30Pwr = 0Dim H As BitDim Tont As ByteDim Tonb As ByteDim Vol_me As ByteDim Inp_ut As ByteDim Att_lr As ByteDim Att_rr As ByteDim Att_lf As ByteDim Att_rf As ByteDim Bas_ss As ByteDim Tre_le As ByteDim Gain As ByteDim Gain_v As ByteDim Gain_d As SingleDim Gain_d1 As SingleDim Gain_d2 As SingleDim Gain_d3 As SingleDim Gain_d4 As SingleDim Temp As Byte'----------------------------------------------------'radio preluat din varinta simpla Declare Sub RadioDim Station As Byte Dim Pll As SingleDim Fset As WordDim Freq As Single                                          ' set freqDim 1st As ByteDim 2nd As ByteDim 3rd As ByteDim 4st As ByteDim 5th As ByteConst Fref = 32.768                                         ' cristal freq radio moduleConst Fg = 250'-------------------------------------------------------------------------------------------Gain_d1 = 0Gain_d2 = 0Gain_d3 = 0Gain_d4 = 0Tont = 8Tonb = 8Gain_v = &B00011000Gain_d = 0Vol_me = &B00100000                                         'default volum -40dBInp_ut = &B01010000                                         'default intrarea stereo1 ;gain 0db   ( 88 )Att_lr = &B11000000                                         'default atenuare lr 0dB   ( 192 )Att_rr = &B11100000                                         'default atenuare rr 0dB   ( 224 )Att_lf = &B10000000                                         'default atenuare lr 0dB   ( 128 )Att_rf = &B10100000                                         'default atenuare rr 0dB   ( 160 )Bas_ss = &B01100111                                         'default 0dB ( 103 )Tre_le = &B01110111                                         'default 0dB ( 119 )'-----------------------------------------------------------------Dim Char_pos As ByteDim Bar_len As WordDim T1 As SingleConst Char_max = 16                                         'number of LCD characters (one row)Deflcdchar 5 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 32        ' barCls                                                         'Cursor OffDeclare Sub MmenuDeclare Sub MplusDeclare Sub MminusDeclare Sub MonoffDeclare Sub ToneshDeclare Sub TonesjDeclare Sub Pwr_onDeclare Sub Pwr_offDeclare Sub Inpt_gainDeclare Sub DisplDeclare Sub Inpt_chgnClsLcd "Script Amplituner"Locate 2 , 1Lcd "2 X 80 W"Wait 2Cls'--incarc toata cofiguratia default in TDA----I2csend &H88 , Vol_meI2csend &H88 , Att_rfI2csend &H88 , Att_lfI2csend &H88 , Att_rrI2csend &H88 , Att_lrI2csend &H88 , Tre_leI2csend &H88 , Bas_ssI2csend &H88 , Inp_ut'---------------------------------------------Call Pwr_offEnable InterruptsReset Portd.7Reset Portd.6DoIf Pwr = 1 Then W = Timer1  If W => 59990 Then   A = 7   Call Mmenu  End IfGetrc5(address , Command)                                   'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End IfSelect Case Command'---- this codes are for my remote , change code to your suit ! ----------------   Case 32 : Call Mmenu                                     'remote command code for CH up   Case 161 : Call Mmenu   Case 33 : Call Mmenu                                     'remote command code for CH down   Case 160 : Call Mmenu   Case 17 : Call Mplus                                     'remote command code for Vol +   Case 145 : Call Mplus   Case 16 : Call Mminus                                    'remote command code for Vol -   Case 144 : Call Mminus   Case 12 : Call Monoff                                    'remote command code for On/Off   Case 140 : Call Monoff   Case 48 : Call Radio   End Select Menu = Pind.4                                              ' Plus = Pind.1                                              ' Minus = Pind.0                                             ' Onoff = Pind.5                                           ' If Menu = 0 Then                                           'now we read the push buttons for command      Waitms 5      Call Mmenu                                            'button for menu presed End If If Plus = 0 Then      Waitms 5      Call Mplus                                            'button Plus presed End If If Minus = 0 Then      Waitms 5      Call Mminus                                           'button Minus presed End If If Onoff = 0 Then      Waitms 5      Call Monoff                                           'button On/off presed End IfEnd IfIf Pwr = 0 Then Getrc5(address , Command)                                  'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End If  Select Case Command '---- this codes are for my remote , change code to your suit ! ----------------  Case 12 : Call Monoff                                     'remote command code for On/Off  Case 140 : Call Monoff  End Select  Onoff = Pind.5     If Onoff = 0 Then      Waitms 10      Call Monoff                                           'button On/off presed     End IfEnd IfLoopEnd'-----------Mmenu-----------------Sub Mmenu:A = A + 1Set Portd.7                                                 'backlight onIf A > 6 Then   A = 0   End IfIf A = 0 Then   Home Upper   Lcd "-    Volume    +"   T1 = Vol_me / 3.9375   Bar_len = 16 - Int(t1)   Waitms 180End IfIf A = 1 Then   Home Upper   Lcd " Select Input   "   Home Lower   Lcd "     Input  " ; C ; "   "   Waitms 180End IfIf A = 2 Then   Cls   Home Upper   Lcd "Radio Station"   Lowerline   Lcd "     Chanel  " ; C ; "  "   Waitms 180   End IfIf A = 3 Then   Home Upper   Lcd "  Right Channel "   D = E / 3.75   Bar_len = Int(d )   Waitms 180End If   Waitms 180   If A = 4 Then   Home Upper   Lcd "  Left Channel  "   D = E / 3.75   Bar_len = Int(d )   Waitms 180End If   Waitms 180If A = 5 Then   Home Upper   Lcd "-    Bass      +"   Bar_len = Tonb   Waitms 180End IfIf A = 6 Then   Home Upper   Lcd "-    Treble    +"   Bar_len = Tont   Waitms 180End IfCall DisplEnd Sub'-----------Mplus-----------------Sub Mplus:'-------regelz volumul-----------------------If A = 0 Then  If Vol_me < 63 Then  Incr Vol_me  T1 = Vol_me / 3.9375  Bar_len = 16 - Int(t1)  I2csend &H88 , Vol_me  End If  Call DisplEnd If'------------Right Front --------------If A = 3 ThenIncr Att_rf If Att_rf > 190 Then Att_rf = 190 End If  If E > 1 Then     Decr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_rf  Call Displ  Waitms 50End If'--------------Left Front--------------If A = 4 ThenIncr Att_lf If Att_lf > 190 Then Att_lf = 190 End If  If E > 1 Then     Decr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_lf  Call Displ  Waitms 50End If'------------reglez Bass--------------------------If A = 5 Then  H = 1  Call Tonesh  Bar_len = Tonb  Call DisplEnd If'------------reglez Treble-----------------------------If A = 6 Then  H = 1  Call Tonesj  Bar_len = Tont  Call DisplEnd If'---------reglez Gain Input--------------------------'---------reglez radio--------------------------If A = 2 ThenH = 1Call RadioWaitms 180End If'---------modific intrarea selectata-----------If A = 1 Then  H = 0  Call Inpt_chgn  Waitms 180End IfEnd Sub'-----------Mminus-----------------Sub Mminus:'------------reglez volum------------------If A = 0 Then  If Vol_me > 0 Then  Decr Vol_me  T1 = Vol_me / 3.9375  Bar_len = 16 - Int(t1)  I2csend &H88 , Vol_me  End If  Call DisplEnd If'---------reglez radio--------------------------If A = 2 ThenH = 0Call RadioWaitms 180End If'-------------Right front--------------If A = 3 ThenDecr Att_rfIf Att_rf < 160 ThenAtt_rf = 160End If  If E < 60 Then     Incr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_rf  Call Displ  Waitms 50End If'-------------left front---------------------If A = 4 ThenDecr Att_lfIf Att_lf < 160 ThenAtt_lf = 160End If  If E < 60 Then     Incr E  End If   D = E / 3.75   Bar_len = Int(d )  I2csend &H88 , Att_lf  Call Displ  Waitms 50End If'---------------reglez Bass----------------If A = 5 Then  H = 0  Call Tonesh  Bar_len = Tonb  Call DisplEnd If'------------reglez Treble------------------If A = 6 Then  H = 0  Call Tonesj  Bar_len = Tont  Call DisplEnd If'-----------reglez Gain Input---------------'---------modific intrarea selectata-----------If A = 1 Then  H = 1  Call Inpt_chgn  Waitms 180End IfEnd Sub'-----------Monoff-----------------Sub Monoff:Pwr = Not Pwr If Pwr = 1 Then Call Pwr_on Else Call Pwr_off End IfEnd Sub'------------Pwr_on-------------------------Sub Pwr_on:Display OnDecr AI2csend &H88 , Vol_meI2csend &H88 , Inp_utI2csend &H88 , Att_rfI2csend &H88 , Att_lfI2csend &H88 , Att_rrI2csend &H88 , Att_lrSet Portd.6                                                 'power relay onSet Portd.7                                                 'backlight onWaitms 500Call MmenuW = 0Timer1 = WEnd Sub'------------Pwr_off-------------------------Sub Pwr_off:Display OffI2csend &H88 , &B11111111I2csend &H88 , &B10011111I2csend &H88 , &B10111111I2csend &H88 , &B11011111Reset Portd.6                                               'power relay offReset Portd.7                                               'backlight offWaitms 500End Sub'------------Tonesh----------------------Sub Tonesh:Select Case HCase 1 : Decr Tonb         If Tonb < 1 Then Tonb = 1Case 0 : Incr Tonb         If Tonb > 15 Then Tonb = 15End SelectSelect Case Tonb   Case 1 : Bas_ss = 96   Case 2 : Bas_ss = 97   Case 3 : Bas_ss = 98   Case 4 : Bas_ss = 99   Case 5 : Bas_ss = 100   Case 6 : Bas_ss = 101   Case 7 : Bas_ss = 102   Case 8 : Bas_ss = 103   Case 9 : Bas_ss = 110   Case 10 : Bas_ss = 109   Case 11 : Bas_ss = 108   Case 12 : Bas_ss = 107   Case 13 : Bas_ss = 106   Case 14 : Bas_ss = 105   Case 15 : Bas_ss = 104End SelectI2csend &H88 , Bas_ssEnd Sub'------------Tonesj--------------Sub Tonesj:Select Case HCase 1 : Decr Tont         If Tont < 1 Then Tont = 1Case 0 : Incr Tont         If Tont > 15 Then Tont = 15End SelectSelect Case Tont   Case 1 : Tre_le = 112   Case 2 : Tre_le = 113   Case 3 : Tre_le = 114   Case 4 : Tre_le = 115   Case 5 : Tre_le = 116   Case 6 : Tre_le = 117   Case 7 : Tre_le = 118   Case 8 : Tre_le = 119   Case 9 : Tre_le = 126   Case 10 : Tre_le = 125   Case 11 : Tre_le = 124   Case 12 : Tre_le = 123   Case 13 : Tre_le = 122   Case 14 : Tre_le = 121   Case 15 : Tre_le = 120End SelectI2csend &H88 , Tre_leEnd Sub'----------Inpt_chgn-------------Sub Inpt_chgn:Select Case HCase 0 : Decr C         If C < 1 Then C = 1Case 1 : Incr C         If C > 4 Then C = 4End SelectSelect Case C   Case 1 : Mask = &B00000000   Lowerline   Lcd "      DVD       "   Case 2 : Mask = &B00000001   Lowerline   Lcd "      PC       "   Case 3 : Mask = &B00000010   Lowerline   Lcd "      Mp3       "   Case 4 : Mask = &B00000011   Lowerline   Lcd "     Radio      "End SelectTemp = Inp_ut And &B11111100Inp_ut = Temp Or MaskI2csend &H88 , Inp_utW = 0Timer1 = WEnd Sub'---------rado-----------------' varianta radio simpla Sub radio:' pind.1 legat buton suplimentar' pind.2 legat buton suplimentar'----------prgramul nemodificat care merge pe placa , folosesc comand pentru a schimba , am incercat cu alta variabila fara succes , cumva comand se reseteaza dupa un timp'main programDo ' incepe program varianta simpla Getrc5(address , Command)                                   'read if we have remote ir command  If Address = 10 Then     Command = Command And &B01111111  End IfIf Pind.0 = 0 Then  ' selectez postul radio 1Waitms 3            ' debounce buton Command = 1         ' simulez comand 1End IfIf Pind.1 = 0 ThenWaitms 3Command = 2End IfIf Pind.4 = 0 ThenWaitms 3Command = 3End IfIf Pind.5 = 0 ThenWaitms 4Command = 4End IfSelect Case Command ' selectez cazul comanda Case 1              ' primul cazCls                 ' sterge lcd Lcd "     Pro FM     " 'afiseaza pro fmLowerline              ' linia 2 lcd Lcd Freq               ' afiseaza variabila freq Set Portb.4            ' seteza pinulb 4 up cat timp se trimit datele set port.b3 	       ' led de proba Freq = 102.8           ' setez frecventaCase 2ClsLcd "     Vibe FM    "LowerlineLcd FreqSet Portb.4Freq = 92.1Case 3ClsLcd "    Magic FM    "LowerlineLcd FreqSet Portb.4Freq = 90.8Case 4ClsLcd "    Europa FM   "LowerlineLcd FreqSet Portb.4Freq = 106.7End SelectPll = Freq * 1000  ' ceva calculePll = Pll + FgPll = Pll * 4Pll = Pll / Fref Fset = Int(pll)1st = High(fset)Reset 1st.7                                                 'not muteReset 1st.6                                                 'not search2nd = Low(fset)3rd = &B000100004st = &B000100105th = &B00000000I2cstart ' pregatesc i2cI2cwbyte &HC0                                               'adresa icI2cwbyte 1st ' scriu dateleI2cwbyte 2ndI2cwbyte 3rdI2cwbyte 4stI2cwbyte 5thI2cstop ' poresc i2cReset Portb.4 ' datele au fost trimise resetez pinul porb 4 low pentru stabilizarea postuluireset port.b3 ' sting led de proba Loop ' reiau codu de la inceput ' incepe cod statieW = 0Timer1 = WEnd Sub ' inchid sub radio'----------Displ---------------Sub Displ:If A <> 1 Then  If A <> 2 Then   Locate 2 , 1                                             'set LCD first character position   For Char_pos = 1 To Char_max                             'number of characters    If Char_pos <= Bar_len Then                             'print one bar      Lcd Chr(5)                                            'print special char                                         '    Else      Lcd Chr(32)                                           'print spaces to fill row    End If   Next  End IfEnd IfW = 0Timer1 = WEnd Sub
Link spre comentariu

Salut , nu am vazut nicaieri unde initializezi portul B , de ex :Config portb.4 =outputConfig portb.2= outputAi facut asta ?Apoi care dintre variante zici ca nu merge , ca sunt un pic confuz .Pune din nou sau spune care e varianta ca sa ma uit eu pe programul tau .

am schimbat semnatura la profil poate deranjeaza nu sunt manelist , e pt un prieten situ facut de mine , am uploadat iar codu
Link spre comentariu

am schimbat semnatura la profil poate deranjeaza nu sunt manelist , e pt un prieten situ facut de mine , am uploadat iar codu

Ok .Te rog sa explici clar ce anume nu merge ca am recitit de vreo 4 ori si nu inteleg ce nu merge .In programul meu sunt multe variiabile care se schimba in diferite rutine ,unele destul de imbirligate , de aceea ar fi trebuit ca tu sa declari pentru partea de radio noi variabile care sunt alterate doar in partea de radio .Explica cu subiect si predicat plus semne de punctuatie ca sa te pot ajuta .Multumesc.
Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum
×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări