SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By zapnspark
#37817
The following is an example of setting up the NS73M FM transmitter module using code written in BASCOM-AVR for the ATMEL ATTINY13.
This code has been tested.
Code: Select all
' Author:    ZAPNSPARK (Jim G.)
' Program:   FMxmtr1.bas
' Purpose:   Sets up the NS73M module (SPARKFUN.COM SKU# WRL-08482)
'            to transmit in stereo at 93.9 MHz, 73 us pre-emphasis, 2 mW
'            transmit power and 200 mV audio input for 100% modulation.
' Date:      10-31-2007
' Version    1.23
' Compiler:  BASCOM-AVR IDE version 1.11.8.9 (MCS Electronics - MCSELEC.COM)
' Processor: ATMEL ATTINY13
' Notes:     ATTINY13 Fuses set for 4.8 MHz internal RC oscillator &
'            brownout at 2.7 volts.
'            NS73M Module and ATTINY13 operate at 3.3 VDC.
'            NS73M module IIC pin is grounded. TEB is not connected.
' Legal:     This code is intended for non-commercial, DIY experimenter
'            use only.
'            Check local & country regulations for maximum radiated power,
'            interference and other possible transmission restrictions.
'


$regfile = "attiny13.dat"               ' ATMEL ATTINY13 processor
$crystal = 4800000                      ' Internal RC osc. fuse set to 4.8 MHz

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 MHz)
   Gosub Sendxmtr                       ' NOTE: above value may require tweaking.
   Regxmtr = &H04 : Datxmtr = &H2C      ' Upper byte frequency  (93.9 MHz)
   Gosub Sendxmtr                       ' See the data sheet to calculate freq.
   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



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
By cairn
#38995
Just wanted to say thanks for sharing your code. I've been working on getting the NS73M working with an Arduino (I'll be posting my code shortly) and it was helpful to see how you did it.
By randofo1
#42448
I'm trying to convert your code into C for use with the Arduino and I am just about there with it but was wondering what is up with &H00? Maybe I'm converting it incorrectly to (0X00), but it seems like an invalid character to me. At least the Arduino programmer really feels that way.
By randofo1
#42449
problem resolved... will post my code hopefully shortly after I verify it works.