پاسخ : تولید صدای اعداد توسط میکرو
پس ISD5216 و APR9301 و APR9600 و... که گفتین به درد نمی خورن؟
پس ISD5216 و APR9301 و APR9600 و... که گفتین به درد نمی خورن؟
' **** In The Name Of God **** 'desined by O&H team's Omid Habibi & H.Ir [iran-shiraz] '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '#####desined by O&H team --> Omid Habibi & H.Ir [IRAN-SHIRAZ]##### 'something about our injucate board 'this board have this compo nent 'VS1003 RFM12bp RFM12B MMC LCD2*16 DS1307 lm386 'All the hardwere have code and tested 'vs1003 for this component we wrote the play and recorder code even u can 'choice the track with mmc_fat engine 'for rfm12 i wrote the send & recive code and find the sub for test mode '####attention 'some code was wrote but hav'nt a hardwere because we made this board embedde 'you can find the pcb & schematic for other code in the www.eca.ir 'the pcb & schematic like MT88E43 for caller-id and some thing elese like 'AD7780 even you can ask your question about this componnent of our teacher like 'MR.Ahmad Koohestani about analog component (for example ad7780 & other's ;) ' www.eca.ir ' you can visit me---^ ;) '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $regfile = "M64def.dat" $crystal = 14745600 $swstack = 256 $hwstack = 256 $framesize = 512 $baud = 1200 'it's find for Caller_id mt88e43 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Config Porta = Output Config Portb = Output Config Portc = Output Config Porte = Output Config Portf = Input '***b careful it's conected to mmc ;( first disconect pin in moterboard Config Portg = Output '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2 Config Lcd = 16 * 2 Cursor Off : Cls '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '$lib "mcsbyte.lbx" ' for smaller code $lib "ds1307clock.lib" ' modified lib Config Sda = Portd.1 : Config Scl = Portd.0 Const Ds1307w = &HD0 ' Addresses of Ds1307 clock Const Ds1307r = &HD1 Config Clock = Soft ' this will dim the bytes automatic '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dim Vs_w As Byte Dim Vs_r As Byte Dim Vs_mode_ad As Byte Dim Vs_bass_ad As Byte Dim Vs_clock_ad As Byte Dim Vs_aiaddr_ad As Byte Dim Vs_vol_ad As Byte Dim Vs_command As Byte Dim Data_high As Byte Dim Data_low As Byte Dim Buffer(512) As Byte Dim S As String * 50 Dim S2 As String * 50 Dim Spi_rec As Word Dim Spi_val As Word Dim Cmd_and As Word Dim Send_data As Word Dim Rec_data As Byte Dim Rec As Word Dim Rf_buffer(11) As Byte Dim Weekday As Byte Dim L As Long , D As Double Dim B As Byte , Chk As Byte , J As Byte Dim Ff As Byte Dim Hdat0 As Byte : Hdat0 = 7 Dim Hdat1 As Byte : Hdat1 = 8 '--------------------------------------------------------------------------------- Declare Sub Vs_reset() Declare Sub Vs_init() Declare Sub Vs_read() Declare Sub Vs_write() Declare Sub Vs_play() Declare Sub Vs_record() Declare Sub Mmc_init() Declare Sub Mmc_dir() Declare Function Mmc_dir_select(s_dir As String)as String Declare Function Rf_wrt_cmd(byval Cmd As Word) As Word Declare Sub Rf_init() Declare Sub Rf_send(byval Abyte As Byte) Declare Sub Rf_port_init() Declare Sub Rf_recv() Declare Sub Rf_data() Declare Sub Rf_send_test() Declare Sub Rf_recive_test() Declare Sub Clk_start() Declare Sub Ad7780() Declare Sub Main_menu() Declare Sub Caller_id() '-------------------------------------------------------------------------------------- '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dreq Alias Pinb.5 'b.5 Xrst Alias Portb.6 'b.6 Xdcs Alias Portb.4 'b.4 Xcs Alias Portb.0 Mosi Alias Portb.2 Sclk Alias Portb.1 Miso Alias Pinb.3 Rf_sck Alias Portc.1 Rf_sdo Alias Pinc.0 Rf_sdi Alias Portc.2 Rf_sel Alias Portc.3 Rf_int Alias Pinc.4 Rf_tx Alias Portc.5 Rf_rx Alias Portc.6 Mmc_gnd Alias Porta.1 Mmc_vcc Alias Porta.0 Led_blue Alias Portg.0 Led_red Alias Portg.1 Key_down Alias Pine.7 Key_up Alias Pine.6 Config Key_up = Input : Config Key_down = Input : Set Porte.6 : Set Porte.7 Config Mmc_vcc = Output Config Mmc_gnd = Output Config Dreq = Input Config Xcs = Output Config Xdcs = Output Config Xrst = Output Config Mosi = Output Config Miso = Input Config Sclk = Output Config Rf_sck = Output Config Rf_sdo = Input Config Rf_sdi = Output Config Rf_sel = Output Config Rf_int = Input Config Rf_tx = Output Config Rf_rx = Output Reset Rf_tx : Reset Rf_rx Config Debounce = 150 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '$include "Config_AVR-DOS.BAS" $include "AVR-DOS.BAS" $include "Config_MMC.bas" If _min > 59 Then Call Clk_start If _sec > 59 Then Call Clk_start If _hour > 23 Then Call Clk_start Main: '******************************************************************************* ' it's my main program ' by:omid habibi ' ;) 'write your code here 'Do : Call Vs_play : Loop 'for example ---^ Call Main_menu Cls : Lcd "Start" : Waitms 1 Call Mmc_init Cls : Lcd "Start2" : Waitms 1 'Call Vs_reset Cls : Lcd "Start3" : Waitms 1 Call Vs_init Cls : Lcd "Start4" : Waitms 1 Dim Play_count As Byte Dim Sss As String * 1 Replay_sound: Cls : Home Lcd "s is " ; S Wait 2 For Play_count = 0 To 9 Sss = Str(play_count) S = Sss + ".MP3" Ff = Freefile() Cls : Home Lcd "playing " : Lowerline : Lcd S ; " <<" Open S For Binary As #ff ' should be 32 for binary 'Open "1.mp3" For Binary As #ff Set Portg.0 Reset Portg.1 'this is how simple it is 'Time$ = "00:00:00" Do Incr B If B > 30 Then Toggle Portg Incr _sec If _sec > 59 Then Incr _min _sec = 0 End If Locate 1 , 9 : Lcd Time$ B = 0 End If Get #ff , Buffer(1) , , 512 Reset Xdcs For L = 1 To 512 Reset Xdcs Shiftout Mosi , Sclk , Buffer(l) , 1 Set Xdcs Bitwait Dreq , Set Next L Set Xdcs If Key_down = 0 Then Vs_command = 0 : Data_high = 9 : Data_low = 0 : Call Vs_write Lowerline : Lcd " bus " End If If Key_up = 0 Then Goto Main Loop Until Eof(#ff) <> 0 Close #ff Next Play_count Goto Replay_sound '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Call Main_menu 'this is all of my hardwere 'it;s was tested and it work's ;) 'for first time plz dont tuch the code and test your mainboard 'then you can play with code and be a perfect ;) 'i hope this code and hardwere be well for yourself 'desined by O&H team's omid habibi & havzhin iranpanah [iran-shiraz] '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Main_menu Local All_sub_menu As Byte , Select_sub_menu As Byte Dim Sub_menu(13) As String * 12 Remain: Set Led_blue : Reset Led_red All_sub_menu = 10 'number of menu show Sub_menu(1) = ".MP3 player" Sub_menu(2) = ".Caller ID " Sub_menu(3) = ".RFM12 SEND" Sub_menu(4) = ".RFM12 Recv" Sub_menu(5) = ".MEMORY DIR" Sub_menu(6) = ".RTC CLICK" Sub_menu(7) = ".Ad7780 IC" Sub_menu(8) = ".Recording " Sub_menu(9) = ">>>>>>EXIT<<<<<" Sub_menu(10) = ">>>>>>>><<<<<<<" Select_sub_menu = 1 : Cls : Home : Lcd ">>1" ; Sub_menu(1) : Lowerline : Lcd "2" ; Sub_menu(2) : Locate 1 , 15 : Lcd "<<" 'Select_sub_menu = 7:Cls : Home : Lcd ">>7" ; Sub_menu(7) : Lowerline : Lcd "8" ; Sub_menu(8) : Locate 1 , 15 : Lcd "<<" Do If Key_up = 0 Then Waitms 100 If Key_up = 0 Then Toggle Portg Incr Select_sub_menu B = Select_sub_menu + 1 If B > All_sub_menu Then : B = All_sub_menu : Select_sub_menu = 1 : End If Cls : Home : Lcd ">>" ; Select_sub_menu ; Sub_menu(select_sub_menu) : Locate 1 , 15 : Lcd "<<" : Locate 2 , 1 : Lcd B ; Sub_menu(b) Waitms 100 End If End If Debounce Key_down , 0 , Sub_menu_chek Loop Sub_menu_chek: Cls : Home : Lcd "Processing..." : Lowerline : Lcd "choice is " ; Select_sub_menu : Waitms 300 : Cls Select Case Select_sub_menu Case 1 S = Mmc_dir_select(s) : Call Vs_init : Call Vs_play Case 2 Call Caller_id Case 3 Call Rf_send_test Case 4 Call Rf_recive_test Case 5 Call Mmc_dir Case 6 Cls : Home : Lcd " " ; Time$ : Lowerline : Lcd " " ; Date$ : Wait 3 Case 7 Call Ad7780 Case 8 Call Vs_init Call Vs_record Do Vs_command = 8 Call Vs_read Home Lcd Bin(data_high) ; Bin(data_low) Lowerline Vs_command = 9 Call Vs_read Lcd Bin(data_high) ; Bin(data_low) If Key_up = 0 Then Goto Remain Toggle Portg Loop Case 9 Exit Sub End Select Goto Remain End Sub '_______________________________________________________________________________ '_______________________________________________________________________________ '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Function Mmc_dir_select(s_dir As String * 16) As String * 16 Call Mmc_init 'create file.list in MMC Local All_mp3_menu As Byte , Select_mp3_menu As Byte , Number_mp3 As Byte Dim Sub_mp3(50) As String * 12 S = Dir( "*.mp3") Number_mp3 = 0 While Len(s) > 0 S = Dir() : Incr Number_mp3 'here b is number of the mp3 file's If Len(s) < 13 Then Sub_mp3(number_mp3) = S Wend Sub_mp3(number_mp3 + 1) = Str(number_mp3) + " MP3 File" 'Sub_mp3(number_mp3 + 2) = "------------" Remain_mp3: Set Led_blue : Reset Led_red All_mp3_menu = Number_mp3 + 1 'number of menu show Select_mp3_menu = 1 : Cls : Home : Lcd ">>" ; Sub_mp3(1) : Lowerline : Lcd Sub_mp3(2) : Locate 1 , 15 : Lcd "<<" 'Select_sub_menu = 7:Cls : Home : Lcd ">>7" ; Sub_menu(7) : Lowerline : Lcd "8" ; Sub_menu(8) : Locate 1 , 15 : Lcd "<<" Do If Key_up = 0 Then Waitms 100 If Key_up = 0 Then Toggle Portg Incr Select_mp3_menu B = Select_mp3_menu + 1 If B > All_mp3_menu Then : B = All_mp3_menu : Select_mp3_menu = 1 : End If Cls : Home : Lcd ">>" ; Sub_mp3(select_mp3_menu) : Locate 1 , 15 : Lcd "<<" : Locate 2 , 1 : Lcd Sub_mp3(b) Waitms 100 End If End If Debounce Key_down , 0 , Sub_mp3_chek Loop Sub_mp3_chek: If Select_mp3_menu > Number_mp3 Then Goto Remain_mp3 Mmc_dir_select = Sub_mp3(select_mp3_menu) End Function '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Mmc_init() Set Mmc_vcc : Set Mmc_gnd : Waitms 100 B = Drivereset() : B = Driveinit() $external Waitms If Gbdriveerror <> 0 Then Cls : Lcd "Error Config" : Lowerline : Lcd Gbdriveerror : Wait 3 End If B = Initfilesystem(1) 'init file system If B <> 0 Then Cls : Lcd " Error MMC" ; B : Wait 3 End If End Sub '_______________________________________________________________________________ '_______________________________________________________________________________ '_______________________________________________________________________________ '_______________________________________________________________________________ '----------------------------vs_sub and function's------------------------------ '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Vs_record() 'alan ma roy oon 800 rikhtim yami faghat halate spi ro 1 kardim hala '800= &b0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 '------------------------------------------line in for record **** '----------------------------------------filtere bala gozar ***** '--------------------------------------fal boodane adpcm record **** '---------------------------------halate spi **** '-------------------------------eshterak gozarie faal sazie sdi '-----------------------------tartibe vroodie sdi '--------reset soft ************ 'Bit 0 == Mode ================^^^^^^^^^^^^ 'Bit 1 == Status 'Bit 2 == boss 'Bit 3 == clockf 'Bit 4 == decode time 'Bit 5 == audata *dadehaye sotie goonagoon 'Bit 6 == wram dadehaye ram baray r/w 'Bit 7 == hdat0 'Bit 8 == hdat1 'Bit 9 == aiaddr 'Bit 10 == volume 'Bit 11 == AICTRL0 'Bit 12 == AICTRL1 'Bit 13 == AICTRL2 'Bit 14 == AICTRL3 Reset Xrst Waitms 1 Set Xrst Waitus 500 Bitwait Dreq , Set Vs_command = 0 'data_high = &B01110000 'for digital input '8 Data_high = &B00110000 'for microphone Data_low = 4 Call Vs_write End Sub '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Vs_play() Call Mmc_init Call Vs_reset Call Vs_init Ff = Freefile() Cls : Home Lcd "playing " : Lowerline : Lcd S ; " <<" Open S For Binary As #ff ' should be 32 for binary 'Open "1.mp3" For Binary As #ff Set Portg.0 Reset Portg.1 'this is how simple it is 'Time$ = "00:00:00" Do Incr B If B > 30 Then Toggle Portg Incr _sec If _sec > 59 Then Incr _min _sec = 0 End If Locate 1 , 9 : Lcd Time$ B = 0 End If Get #ff , Buffer(1) , , 512 Reset Xdcs For L = 1 To 512 Reset Xdcs Shiftout Mosi , Sclk , Buffer(l) , 1 Set Xdcs Bitwait Dreq , Set Next L Set Xdcs If Key_down = 0 Then Vs_command = 0 : Data_high = 9 : Data_low = 0 : Call Vs_write Lowerline : Lcd " bus " End If If Key_up = 0 Then Goto Main Loop Until Eof(#ff) <> 0 Close #ff End Sub '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Vs_reset() Vs_w = 2 : Vs_r = 3 Vs_command = 0 : Data_high = 0 : Data_low = 4 Call Vs_write End Sub '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Vs_read() Vs_r = 3 'Reset Xrst 'Waitms 1 'Set Xrst 'Waitus 500 'Bitwait Dreq , Set Reset Xcs Shiftout Mosi , Sclk , Vs_r , 1 Shiftout Mosi , Sclk , Vs_command , 1 Data_high = 12 : Data_low = 12 Shiftin Miso , Sclk , Data_high , 1 Shiftin Miso , Sclk , Data_low , 1 Set Xcs Waitus 500 Bitwait Dreq , Set End Sub '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sub Vs_write() Vs_w = 2 Reset Xcs Shiftout Mosi , Sclk , Vs_w , 1 Shiftout Mosi , Sclk , Vs_command , 1 Shiftout Mosi , Sclk , Data_high , 1 Shiftout Mosi , Sclk , Data_low , 1 Set Xcs Waitus 500 Bitwait Dreq , Set End Sub '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Sub Vs_init() Vs_w = 2 Vs_r = 3 Vs_mode_ad = 0 'neshanie sabat 'alan ma roy oon 800 rikhtim yami faghat halate spi ro 1 kardim hala '800= &b0000100000000000 '---------^line in for record **** '----------^filtere bala gozar '-----------^fal boodane adpcm record **** '------------^halate spi **** '-------------^eshterak gozarie faal sazie sdi '--------------^ tartibe vroodie sdi '---------------^ ' kole 16 bit in goone ast Vs_bass_ad = 2 Vs_clock_ad = 3 Vs_aiaddr_ad = 10 Vs_vol_ad = 11 Set Xcs Set Xdcs Set Xrst Bitwait Dreq , Set Reset Xrst Waitms 1 Set Xrst Waitus 500 Bitwait Dreq , Set Vs_command = Vs_mode_ad 'data_high = &B00110000:data_low = 4 Data_high = 8 : Data_low = 0 Call Vs_write Vs_command = Vs_clock_ad 'data_high = &H80 : data_low = 0 Data_high = &B11111011 : Data_low = &B11101000 'for 12mhz crystal Call Vs_write Vs_command = Vs_aiaddr_ad Data_high = 0 : Data_low = 0 Call Vs_write Vs_command = Vs_vol_ad Data_high = 0 : Data_low = 0 Call Vs_write 'Reset Xcs 'Spiout Vs_w , 1 'Spiout Vs_bass_ad , 1 'Tanzime Bass va Treble 'data_high = &H80 'data_low = 0 'Spiout data_high , 1 'Spiout data_low , 1 'Set Xcs 'Waitus 500 'Bitwait Dreq , Set End Sub
دیدگاه