' ######################################################################## ' # RF12- E M P F Ä N G E R ATMega8 interner Takt 8Mhz Fuse 0100 Ckopt = 1 ' # by Holli modified jr 5/2013 Stand 28.05.2013 ' # Laborplatine - RFM12 on board ' # FIFO Read using RFM "Receiver FIFO Read Command" - hB0xx ' # NIRQ Polling ' # Stand 13.07.2013 ' ######################################################################## $regfile = "m8def.dat" $hwstack = 40 $swstack = 40 $framesize = 40 $crystal = 8000000 '$baud = 19200 'nur zum Testdrucken 'Baud = 19200 Config Portd.2 = Input Nirq Alias Pind.2 Led Alias Portd.4 'LED zur Kontrolle Config Portd.4 = Output Config 1wire = Portd.5 ' Pin für 1wire Schnittstelle festlegen, Dim Sc(9) As Byte Dim T As Integer Dim T_ext As Integer Dim Ti As Single Dim Ti_ext As Single Dim T2 As Integer Dim Tmp As Byte Dim I As Byte Dim Y As Byte Dim Count As Byte Dim Temp As Byte Dim Rx(9) As Byte Dim Cmd(2) As Byte Dim Fifo(4) As Byte Declare Sub Rf_cmd(byval Wert As Word) ' # LCD Config Lcd = 16 * 1a Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5 Cls Cursor Off Noblink ' # SPI conf Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16 , Noss = 0 , Spiin = &HB0 Spiinit Waitms 300 Toggle Led ' ### init Daten für RFM12 ### Call Rf_cmd(&H0000) 'read status Call Rf_cmd(&Hc0e0) 'low battery, clock 10 MHz Call Rf_cmd(&H80d7) 'Configuration: 433 MHzband, 12pf Call Rf_cmd(&H82d8) 'power management: enable receiver, enable clock output Call Rf_cmd(&Hc2ac) 'data filter command Call Rf_cmd(&Ha620) 'Frequency: 433 MHz 'Call Rf_cmd(&Hc611) 'Datarate: 19.2 kbit 'Call Rf_cmd(&Hc623) 'Datarate: 9,6 kbit 'Call Rf_cmd(&Hc646) 'Datarate: 4,8 kbit Call Rf_cmd(&Hc691) 'Datarate: 2,4 kbit Call Rf_cmd(&H94a1) 'receiver setting: 134kHz, -97dbm Call Rf_cmd(&Hc2ac) 'data filter: Call Rf_cmd(&Hc483) 'AFC: alt c4f3 Call Rf_cmd(&H9850) 'TX control Call Rf_cmd(&He000) 'wake-up Call Rf_cmd(&Hc800) 'low duty-cycle Call Rf_cmd(&Hca81) 'Reset FIFO alt = caf1 Call Rf_cmd(&Hca83) 'enable FIFO alt = caf3 Call Rf_cmd(&H0000) 'read status Do Toggle Led Locate 1 , 1 For Count = 1 To 9 Bitwait Nirq , Reset Spiin Fifo(1) , 2 Rx(count) = Fifo(2) Next '## Anfang Externer Ds 1820 ############### T = Makeint(sc(1) , Sc(2)) ' aus zwei bytes ein integer machen Ti = T ' integer in single umwandeln Ti = Ti * 0.5 ' Nachkommastelle Lcd "Ext " Lcd Fusing(ti , "##.#" ) ' format Call Rf_cmd(&H0000) 'read status Call Rf_cmd(&Hca81) 'Reset FIFO Call Rf_cmd(&Hca83) 'enable FIFO '## Ende externer DS 1820 ############### '############## interner DS1820 ############# 1wreset 1wwrite &HCC 1wwrite &H44 Waitms 500 'DS read 1wreset ' Initialisierung 1wwrite &HCC ' überspringe ROM-Befehl 1wwrite &HBE ' Temperatur auslesen Sc(1) = 1wread(9) T_ext = Makeint(sc(1) , Sc(2)) ' aus zwei bytes ein integer machen Ti_ext = T_ext ' integer in single umwandeln Ti_ext = Ti_ext * 0.5 ' Nachkommastelle Locate 2 , 1 : Lcd "Int "; ' formatieren Lcd Fusing(ti_ext , "##.#" ) Waitms 300 '################### Ende interner DS 1820############################### Loop End 'Sub Routinen Sub Rf_cmd(byval Wert As Word) Cmd(2) = Wert And 255 Shift Wert , Right , 8 Cmd(1) = Wert Spiout Cmd(1) , 2 End Sub