PDA

View Full Version : NS73M fm radio trasmitter



Boris
- 30th December 2008, 14:59
Have somebody used this chip (from sparkfun.com)?
I'm trying to read the registers, but my firmware don't works. :cool:

SmugWimp
- 18th January 2009, 05:32
Boris, Any luck on this? I will be moving into an NS73M from a BH1417.

Boris
- 19th January 2009, 07:53
The NS73M works without problem, but I could not read the registers. I can write them, so I can set the frequency and all parameter, but no read...

SmugWimp
- 20th January 2009, 05:57
Not trying to cheat, but if you would not mind sending me a couple of lines of your sample code so I will have something to work with starting out I would appreciate it.

Reading the registers of the NS73M? I guess my first question is why? I am not sure what the advantage or use would be.

Cheers!

SmugWimp

Boris
- 20th January 2009, 10:22
This is my code:


EEPROM 0,[3,232,0,0] 'FREQ.BYTE1 FREQ.BYTE0 PW SENS
READ 0,FREQ.BYTE1
READ 1,FREQ.BYTE0
READ 2,PW
READ 3,SENS

SETUP:

REG=$0E:VAL=$05:GOSUB SCRIVI ' Software reset
REG=$01:VAL=$B4:GOSUB SCRIVI ' Pilot on, forced subcarrier
REG=$02:VAL=$07:GOSUB SCRIVI ' 2 mW power, Unlock detect on REG=$08:VAL=$1A:GOSUB SCRIVI ' CEX = Band 2
REG=$00:VAL=$A1:GOSUB SCRIVI ' Pwr on, 200 mV audio for 100% modulation

REG=$06:VAL=$1E:GOSUB SCRIVI' Set internal charge pumps





SCRIVI:
I2CWRITE DA,CK,%11001100,REG,[VAL]
RETURN

SmugWimp
- 21st January 2009, 08:54
Boris,

Much Appreciated! Not sure if I can do anything about reading registers, I am just beginning. But I can get anything to work, I will post it here.

Cheers!

SmugWimp

SmugWimp
- 23rd January 2009, 03:16
Hi Boris!

Got my chips in today from Sparkfun, and started reading the datasheet on the NS73M a bit more.

It seems that although the NS73M can read and write, the only thing I can see is that it is 'writing' is an ACK for any commands sent, but that seems to be about the only information that I can find in the datasheet.

If you were (like me) planning to read the NS73M to see what parameters it is currently set at then we may end up going another method.

I suspect I will end up using a "set" of defaults, and then use the PIC to read/modify/write those settings in the EEPROM as needed.

Let me know if you see something different!

Cheers!

Alex

SmugWimp
- 3rd February 2009, 12:23
I guess I am missing some elementary issues, but I cannot seem to figure out why I cannot get this to work.

Here is a sample of my code:




REM Above this is just LCD and button setups...

NS_CK VAR PORTC.1
NS_DA VAR PORTC.2

FREQ VAR WORD 'REM Consisting of FREQ.1 and FREQ.2 (Hi/Lo Byte)
MYREG VAR BYTE 'REM Register of NS73M
MYVAL VAR BYTE 'REM Value for register in NS73M
MYCON VAR BYTE 'REM Control Value for NS73M

START:
'REM The Theory is that we setup all parameters, then turn it on.

MYCON = %11001100 'REM Setup Control Address for NS73M
PAUSE 100 'REM Breathe a moment; let the chip get settled...

I2CWRITE NS_DA,NS_CK,MYCON,$0E,[$05] 'REM SOFTWARE RESET NS73M Chip
PAUSE 100
I2CWRITE NS_DA,NS_CK,MYCON,$01,[$B4] 'REM Pilot On, Subcarrier On
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$02,[$07] 'REM 2mw Power, Unlock Detect ON
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$08,[$1A] 'REM CEX Band 2
PAUSE 10
'REM Again, theory is that I am transmitting on 88.5MHz, as per datasheet...
I2CWRITE NS_DA,NS_CK,MYCON,$03,[$58] 'REM Frequency; Lower Byte
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$04,[$2A] 'REM Frequency; Upper Byte
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$00,[$A3] 'REM Power, 200mv Audio, 75us PE
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$0E,[$05] 'REM SOFTWARE RESET NS73M
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$06,[$1E] 'REM Charge Pumps
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$0E,[$05] 'REM SOFTWARE RESET NS73M
PAUSE 10

REM Just a note to let me know it got through the code unscathed...

LCDOUT $FE, 1
LCDOUT $FE, 2
PAUSE 500
LCDOUT $FE, $80
LCDOUT "Transmitting?"
LCDOUT $FE, $C0
LCDOUT " supposedly..."
PAUSE 1000

END



At first I was trying this with a 16F84A, and moved to a 16F877A just to make sure there was nothing wrong with my chips. I get the same results; nothing.

This is my first attempt at I2C communications, so I am not certain what, if any, feedback I can expect. My current feedback is nothing works, lol!

Any pointers on where my code is lacking, or erroneous, would be greatly appreciated!

Cheers!

SmugWimp

SmugWimp
- 4th February 2009, 09:32
Hold the phone folks; I think I may have a hardware issue. I almost hope so, anyway. heh.

BBIAF...

SmugWimp

SmugWimp
- 4th February 2009, 11:00
No Such Luck. What I thought was a miswiring turned out to be correct. But I did remove some (as of yet) unneeded wires for the buttons, until I get the rest of this moving along. It doesnt work any better, but it is easier to see.

Here is the latest rendition of code:



REM LCD PIN Assignments above...

NS_DA VAR PORTB.1
NS_CK VAR PORTB.2
MYCON VAR BYTE 'REM Control Value for NS73M

START:
'REM The Theory is that we setup all parameters, then turn it on.
MYCON = $CC 'REM Setup Control Address for NS73M
PAUSE 100 'REM Breathe a moment; let the chip get settled...

REM I2CWRITE DATAPIN,CLOCKPIN,CONTROLADDRESS,PORTADDRESS,[DATAINBRACKETS]{, OPTIONALJUMPTOLABEL}

I2CWRITE NS_DA,NS_CK,MYCON,$0E,[$05], BOOHA 'REM SOFTWARE RESET NS73M Chip
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$00,[$A0] 'REM Set it up, dont turn it on yet...
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$01,[$B4] 'REM Pilot On, Subcarrier On
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$02,[$07] 'REM 2mw Power, Unlock Detect ON
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$03,[$58] 'REM Frequency; Lower Byte
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$04,[$2A] 'REM Frequency; Upper Byte
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$08,[$1A] 'REM CEX Band 2
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$00,[$A1] 'REM Ok, Turn it on...
PAUSE 10
I2CWRITE NS_DA,NS_CK,MYCON,$0E,[$05] 'REM SOFTWARE RESET NS73M Chip
PAUSE 100
I2CWRITE NS_DA,NS_CK,MYCON,$06,[$1E] 'REM Charge Pump
PAUSE 10
LCDOUT $FE, 1
LCDOUT $FE, 2
PAUSE 500
LCDOUT $FE, $80
LCDOUT "Transmitting?"
LCDOUT $FE, $C0
LCDOUT " supposedly..."
PAUSE 1000
GOTO THEEND

BOOHA:
LCDOUT $FE, 1
LCDOUT $FE, 2
PAUSE 500
LCDOUT $FE, $80
LCDOUT "No ACK"
LCDOUT $FE, $C0
LCDOUT ":("
PAUSE 1000
GOTO THEEND

THEEND:
END


Interestingly enough, One of the reasons I thought it was a hardware failure, was I could remove one, or both of the I2C lines and still not get an error (evidenced by the optional jump label on the first I2CWRITE command, to reset the NS73M). However, if I "swapped" the lines, then I DID get a "No ACK" error. Weird. I still dont understand that. But it is wired correctly.

I moved back to a 16F84A because it wasnt the problem and I have a bunch that I want to use.

On the 16F84A, Pins A0-4 are used for data and RS for the LCD. Pin B0 is the E pin for the LCD, B1 is the I2C Data line, and B2 is the I2C Clock.

On the SparkFun board, Line In is attached to my Ipod, IIC is attached to +3.3v, LA is attached to Ground, Data to B1, Clock to B2, TEB not connected, VCC to +3.3v and Ground to Ground.

Again, It seems like it "should" work, but alas it does not. Any ideas would be greatly appreciated!

Cheers!

SmugWimp

Tom Estes
- 4th February 2009, 15:23
Just a guess here but the NS73M is not 5V tolerant. The pins connected to the PIC should be level compensated to match the logic levels required for the NS73M or a 3V PIC should be used.

I use the NS73M quite reliably but not in I2C mode and my routines are written in Swordfish so I can't really comment on your code. Sorry I can't help more.....

Tom

SmugWimp
- 5th February 2009, 02:41
Tom, Thanks!

Yeah, I have the NS73M on the end of a 3.3v regulator, and all but the LCD is on 3.3v.

If I cant get I2C working, I guess I will go with the 3 wire... but was hoping not to have to use that extra pin...

So goes life...

Cheers!

SmugWimp

savnik
- 5th February 2009, 13:42
Just a guess here but the NS73M is not 5V tolerant. The pins connected to the PIC should be level compensated to match the logic levels required for the NS73M or a 3V PIC should be used.

I use the NS73M quite reliably but not in I2C mode and my routines are written in Swordfish so I can't really comment on your code. Sorry I can't help more.....

Tom
If you want post the code.
Thanks

Archangel
- 5th February 2009, 18:23
Hello SmugWimp,
16F877a has a bunch of analog stuff, some of it on portC, including C.1 and you must disable to send I²C as that data is digital. How about posting the whole code including the config statements. I would read sec. 4.3 of the data sheet, it explains about using portC in I²C communications and which pins to use. I do not know how much it affects the operation, but portC has Schmitt trigger input buffers. It may be because of that, it will only work on the pins Microchip has designated as I²C , it is certainly worth the effort to check. BTW, I do not see the jump label or a subroutine to be jumped to, must be in the unposted code . . . Have you attempted to try this on PortB ? No S. T. on the inputs there. here is a link of someone who got I²C to work : http://www.picbasic.co.uk/forum/showthread.php?t=5632 Looks like I2CWRITE is not a stand alone statement, looks like it requires all the registers to be set as the datasheet specifys . . . The manual gives the impression this is a bit banged solution, sort of looks like it is not.

Archangel
- 7th February 2009, 20:30
Look at this thread it discusses using I²C w 3.3v . . . http://www.picbasic.co.uk/forum/showthread.php?p=69879#post69879 I noticed a comment re: not using schmitt trigger inputs . . .

SmugWimp
- 8th February 2009, 03:36
Joe,

I appreciate all the help and suggestions.

Here is my code, a schematic, and a photo of my setup.

I have tried all kinds of things, and my underlying suspicion isnt that I am doing something wrong. I am just not finished with what is right.

I have rewritten my code more similar to Boris' snippets, and his seems to work, heh. But mine still does not. Yet.


My Configs are set as follows:

__config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _WRT_OFF & _CPD_OFF & _BODEN_ON & _PWRTE_ON



'''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''
'' NS73M Control Test Environment ''
'''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''
' We are using a PIC 16F877A
'
ADCON1=%00000111
Include "ModeDefs.Bas"
DEFINE OSC 4
TRISB=0
DEFINE LCD_DREG PORTA 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 0 'Define first pin of portb connected to LCD DB4
DEFINE LCD_RSREG PORTA 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 4 'Define Porta pin used for RS connection
DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD

NS_CK VAR PORTB.1 ' I2C Clock Pin
NS_DA VAR PORTB.2 ' I2C Data Pin
NS_CON VAR BYTE ' I2C Device (the NS73M) Control Address/ReadWrite Value
NS_REG VAR BYTE ' NS73M Register Address
NS_VAL VAR BYTE ' NS73M Register Value

NS_CON = %11001100 ' Value of NS73M Address, with "Write" Bit

NS_REG=$0E:NS_VAL=$05:GOSUB WRITEDAMMIT ' Reset the chip right off... They said to.
NS_REG=$01:NS_VAL=$B4:GOSUB WRITEDAMMIT ' Pilot On, Forced Subcarrier On
NS_REG=$02:NS_VAL=$07:GOSUB WRITEDAMMIT ' Full (2mw) Power, Unlock Detect On,
NS_REG=$03:NS_VAL=$58:GOSUB WRITEDAMMIT ' Lower Byte of Freq Address in Hex
NS_REG=$04:NS_VAL=$2A:GOSUB WRITEDAMMIT ' Upper Byte of Freq Address in Hex
NS_REG=$08:NS_VAL=$18:GOSUB WRITEDAMMIT ' CEX Band = 3 (For Now. Different Bands for Different Freq's)
NS_REG=$00:NS_VAL=$A1:GOSUB WRITEDAMMIT ' Xmtr RF On, 200mv input level for 100% Modulation
NS_REG=$0E:NS_VAL=$05:GOSUB WRITEDAMMIT ' Another Reset
NS_REG=$06:NS_VAL=$1E:GOSUB WRITEDAMMIT ' Set the Charge Pumps, whatever Charge Pumps are...
GOTO LCDSTUFF

WRITEDAMMIT:
I2CWRITE NS_DA,NS_CK,NS_CON,NS_REG,[NS_VAL] ' I2CWRITE Command. Supposed to work.
PAUSE 10 ' Don't know if this is necessary, but everyone writing to EEProms use it, I figured it couldn't hurt.
RETURN

LCDSTUFF:
LCDOUT $FE, 1
LCDOUT $FE, 2
PAUSE 500
LCDOUT $FE, $80
LCDOUT " Are We"
LCDOUT $FE, $C0
LCDOUT "Transmitting ??"
PAUSE 1000

THEEND:
END




http://www.smugwimp.com/images/pic/devboard.jpg

http://www.smugwimp.com/images/pic/NS73Schematic.jpg

I know the chip in the schematic says "16F84AP". disregard that. In reality, it is a 16F877A; the pin connections are the same still.

Any ideas would be a godsend. Thanks!

Cheers!

SmugWimp

Archangel
- 8th February 2009, 08:47
Have you pulled up the IIC pin #8

SmugWimp
- 8th February 2009, 11:25
It does not have a resistor on it, but "IIC" on the NS73M Board is tied to +3.3v, yes.

Both the I2C Clock and Data lines are pulled to +3.3v with 1Kohm resistors. I have tried larger values, and it makes no difference.

cheers!

SmugWimp

Bruce
- 8th February 2009, 15:04
XT_OSC might be better for a 4MHz crystal, and BODEN_OFF would help when operating
below the Brown-Out Reset Voltage, but I think the primary show-stopper is trying to run
the non LF version 877A below the minimum operating voltage.

The LF part can operate on 2 to 5.5V. The non LF needs 4 to 5.5V. Check the Electrical
Specifications section in your datasheet.

Brown-Out reset on the non LF part can be anywhere from 3.65V, 4.0V or 4.35V.

SmugWimp
- 9th February 2009, 06:07
Bruce,

Thanks for the info. Hadn't thought of that.

I did a slight rewire to provide +5v to LCD and 877a, and +3.3v to NS73M only.

The 1K Pull up resistors for I2 Data/Clock are also at +5v.

XT_OSC and BODEN_OFF have been implemented on my fuses.

However, still no success.

I appreciate everyone's support and suggestions!! I will keep plugging away. Gotta be me... something...

Cheers!

SmugWimp

Bruce
- 9th February 2009, 13:23
Run the PIC at 5V and just build this simple interface circuit shown in section 2.3.

http://www.standardics.nxp.com/support/documents/i2c/pdf/an97055.pdf

SmugWimp
- 9th February 2009, 13:32
Bruce,

Cool!!! Funny, I saw this circuit at Mike Yancy's Website (http://mikeyancey.com/FM-Stereo-Broadcaster.php) while snooping around for stuff. I thought it was because he was running an Arduino. Guess that points out more ignorance on my part!

I'll have to run into Akihabara to get these parts; nothing like that in my stock. I'll let you know what I find, but I really really appreciate the heads up on this!!

Cheers!

SmugWimp