' Written By:Dave Brown ' Date: 5-25-2008 ' Program: DJB-FM_transmitter.bas ' Sets up NS73M module to transmit in stereo ' 102.9 megahertz ' 73 us pre-emphasis ' 2 milliwatts transmit power ' 200 millivolts audio input for 100% modulation. ' ' Compiler: BASCOM-AVR IDE ' Processor: ATTINY13 ' Fuse programming ' 4.8 megahertz internal RC oscillator ' brownout disabled ' $regfile = "attiny13.dat" 'ATTINY13 processor $crystal = 4800000 'Internal RC osc. fuse set to 4.8 megahertz ' ' NS73M read and write address Const Fmtxwr = &B11001100 'Address and Write to FM Tx Module Const Fmtxrd = &B11001101 'Address and Read from FM Tx Module ' Configure I2C pins Config Scl = Portb.0 'Is serial clock SCL pin 5 Config Sda = Portb.1 'Is serial data SDA pin 6 ' Waitms 50 'Wait for NS73M power up ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H0E 'Register E I2cwbyte &H05 'Software reset I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H01 'Register 1 I2cwbyte &HB4 'Pilot on, forced subcarrier I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H02 'Register 2 I2cwbyte &H07 '2 mW power, Unlock detect on I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' ' (102.9+.304)/0.008192=12598.14 'Calculate for 102.9 MHz ' 12598=&H3136 'Low byte=&H36 high byte=&H31 I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H03 'Register 3 I2cwbyte &H36 'Lower byte frequency (102.9 megahertz) I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H04 'Register 4 I2cwbyte &H31 'Upper byte frequency (102.9 megahertz) I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' ' Set up Bands based on the following ranges: ' Band (CEX) 3 2 1 0 ' Frequency 87.5 --- 90 --- 95 --- 101 --- 108 MHz ' Band 3: 87.5 - 92 CEX=&H1B ' Band 2: 87.5 - 98.6 CEX=&H1A ' Band 1: 93.3 - 103.9 CEX=&H19 ' Band 0: 99.3 - 108 CEX=&H18 I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H08 'Register 8 I2cwbyte &H18 'CEX = Band 0 I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H00 'Register 0 I2cwbyte &HA1 'Pwr on, 200 mV audio for 100% modulation I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H0E 'Register E I2cwbyte &H05 'Software reset I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' I2cstart 'I2C Start I2cwbyte Fmtxwr 'I2C FMTx Slave Addr Write I2cwbyte &H06 'Register 6 I2cwbyte &H1E 'Set internal charge pumps I2cstop 'I2C Stop Waitms 1 'Wait for it to process ' Mcucr = &H38 'Prepare to sleep MCU sleep 'Sleeps processor Do : Loop 'Just in case it wakes up End