'SDR receiver software V1.0 'Si570-C2 1-160 MHz 'PR0032 'DL6ZB build PR003211230312 'The ATtiny25 µP uses the internal clock. The divider fuse is set "off". $regfile = "attiny25.dat" $crystal = 8000000 Config Sda = Portb.4 Config Scl = Portb.3 Dim Status As Byte Dim Band As Byte I2cinit Config Portb.0 = Input Portb.0 = 1 Config Portb.1 = Input Portb.1 = 1 Config Portb.2 = Input Portb.2 = 1 Status = 0 Do Band = Pinb Shift Band , Left , 5 Shift Band , Right , 5 If Band <> Status Then Select Case Band Case 7 : Gosub 20m_init Case 6 : Gosub 80m_init Case 5 : Gosub 40m_init Case 3 : Gosub 30m_init End Select End If Loop 80m_init: ' 80m initialized to 3524 kHz for a 48 kHz soundcard. Frequency = 48 kHz/2 > 24 kHz >> 3524 kHz I2cstart I2cwbyte &HAA 'I2C write address Si570 I2cwbyte 137 I2cwbyte &H10 I2cstop I2cstart I2cwbyte &HAA I2cwbyte 7 I2cwbyte &B10101001 'These binary data sets are the divider factors for the Si570 oscillator. I2cwbyte &B11000010 'These data sets may be different for each oscillator chip and maybe I2cwbyte &B11000110 'calculated everytime a new Si570 is installed. The reason is that the I2cwbyte &B10001110 'built-in crystal oscillator may differ in frequency a few Hertz. This I2cwbyte &B10110000 'can cause a few hundred Hertz difference to that what I measured for I2cwbyte &B00000000 'the Si570 used in my RX. See the Silicon Labs manual for more information. I2cstop Status = 6 Gosub Set_frequency Return 40m_init: ' 40m, 7024 kHz I2cstart I2cwbyte &HAA 'I2C write address Si570 I2cwbyte 137 I2cwbyte &H10 I2cstop I2cstart I2cwbyte &HAA I2cwbyte 7 I2cwbyte &B11100100 I2cwbyte &B00000011 I2cwbyte &B00001010 I2cwbyte &B11110100 I2cwbyte &B01010111 I2cwbyte &B10011001 I2cstop Status = 5 Gosub Set_frequency Return 30m_init: ' 30m, 10124 kHz I2cstart I2cwbyte &HAA 'I2C write address Si570 I2cwbyte 137 I2cwbyte &H10 I2cstop I2cstart I2cwbyte &HAA I2cwbyte 7 I2cwbyte &B11100010 I2cwbyte &B10000010 I2cwbyte &B11101100 I2cwbyte &B01111101 I2cwbyte &B11000000 I2cwbyte &B01110100 I2cstop Status = 3 Gosub Set_frequency Return 20m_init: ' 20m, 14024 kHz I2cstart I2cwbyte &HAA 'I2C write address Si570 I2cwbyte 137 I2cwbyte &H10 I2cstop I2cstart I2cwbyte &HAA I2cwbyte 7 I2cwbyte &B10100010 I2cwbyte &B01000010 I2cwbyte &B11000010 I2cwbyte &B11101101 I2cwbyte &B10011111 I2cwbyte &B00010100 I2cstop Status = 7 Gosub Set_frequency Return ' set frequency and start Si570 DCO Set_frequency: I2cstart 'register 137 -new frequency- I2cwbyte &HAA I2cwbyte 137 I2cwbyte 0 I2cstop I2cstart 'register 125 DCO start I2cwbyte &HAA I2cwbyte 135 I2cwbyte &H40 I2cstop Return