' Author: Jim Gillespie ' Program: FMxmtr1.bas ' Purpose: Sets up NS73M module (SPARKFUN.COM) to transmit in stereo at ' 93.9 megahertz, 73 us pre-emphasis, 2 milliwatts transmit power and ' 200 millivolts audio input for 100% modulation. ' Date: 10-30-2007 ' Version 1.22 ' Compiler: BASCOM-AVR IDE version 1.11.8.9 (MCS Electronics - MCSELEC.COM) ' Processor: ATMEL ATTINY13 ' ATTINY13 Fuses set for 4.8 megahertz internal RC oscillator & ' brownout at 2.7 volts. ' NS73M Module and ATTINY13 operate at 3.3 VDC. ' NS73M module IIC pin is grounded. ' Legal This code is free and intended for experimenter and DIY use only. ' I assume no responsibility for improper use of this code. ' $regfile = "attiny13.dat" ' ATMEL ATTINY13 processor $crystal = 4800000 ' Internal RC osc. fuse set to 4.8 megahertz Config Portb = Output ' Port B all outputs Portb = 0 ' Set all port B pins low Ck Alias Portb.2 ' Ck is SPI clock to module Da Alias Portb.1 ' Da is SPI data to module La Alias Portb.0 ' La is SPI latch pulse to module Dim Regxmtr As Byte ' Module register number (4 bits) Dim Datxmtr As Byte ' Module 8 bit data ( 8 bits ) Declare Sub Sendxmtr() ' Sends SPIish type info. to module Waitms 50 ' Wait some for power up settling Regxmtr = &H0E : Datxmtr = &H05 ' Software reset Gosub Sendxmtr Regxmtr = &H01 : Datxmtr = &HB4 ' Pilot on, forced subcarrier Gosub Sendxmtr Regxmtr = &H02 : Datxmtr = &H07 ' 2 mW power, Unlock detect on Gosub Sendxmtr Regxmtr = &H03 : Datxmtr = &HEA ' Lower byte frequency (93.9 megahertz) Gosub Sendxmtr ' NOTE: above value may require tweaking Regxmtr = &H04 : Datxmtr = &H2C ' Upper byte frequency (93.9 megahertz) Gosub Sendxmtr Regxmtr = &H08 : Datxmtr = &H1A ' CEX = Band 2 Gosub Sendxmtr Regxmtr = &H00 : Datxmtr = &HA1 ' Pwr on, 200 mV audio for 100% modulation Gosub Sendxmtr ' NOTE: 75 uS pre-emphasis (North America) Regxmtr = &H0E : Datxmtr = &H05 ' Software reset Gosub Sendxmtr Regxmtr = &H06 : Datxmtr = &H1E ' Set internal charge pumps Gosub Sendxmtr Mcucr = &H38 ' Prepare to sleep MCU sleep ' Sleeps processor Do : Loop ' Just in case it wakes up Sub Sendxmtr() ' Sends SPIish data to module ( 12 bits) Shiftout Da , Ck , Regxmtr , 2 , 4 , 1 ' Send 4 bits of register number Shiftout Da , Ck , Datxmtr , 2 , 8 , 1 ' Send 8 bits of data Waitus 1 ' Short wait Set La ' Set latch output Waitus 4 ' Short wait Reset La ' Reset latch output Return End Sub End