Shop OBEX P1 Docs P2 Docs Learn Events
FM Radio 27984 — Parallax Forums

FM Radio 27984

davi_cdavi_c Posts: 3
edited 2014-03-12 11:12 in General Discussion
Hello,

Is there any one that I've built code using Hi-Tech software to interact with the FM receiver 27984? The main reason is that I've learn C coding with Hi-Tech software and the MCU that I'm using is PIC16F887. I've been able to "decode" a part of the propelller code but it gives me a lot of headaches. Any help or small piece of code in C from which I can start from will be greatly appreciated.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-11 11:35
    I've translated some code from C to Spin and I think there are programs that will do the translation for you. (There's one to translate from Spin into C.) I don't recall the names of these programs but if you're interested I'm sure someone could point you in the right direction.

    I was just looking at the code for the radio and I think I understand it well enough to answer any question you might have. If you want to continue to translate to C you're welcome to ask questions about parts of the program you don't understand.

    It looks like the radio is an I2C device so you may want to use an I2C library to communicate with it.

    I recently worked on an I2C device and I was surprised to see many examples of Spin I2C code not perform I2C transactions correctly. I just checked the radio code and it does look correct though the I2C lines are driven high and low rather than just driven low.

    Is there a specific section of code giving you trouble?
  • davi_cdavi_c Posts: 3
    edited 2014-03-11 12:05
    Hello Duane. I have an example of i2c source code in C code from Hi-Tech software. I understand most of the code from Hi-Tech. Here's where I have trouble (I don't know much about programming by the way): What is the module address? I have seen 0x20 and 0x11. To interface with the tuner (27984), at initial startup, should I set every register one after the other like data for register 0x02, 0x03 and so on or can I simply ask for a specific register with a specific data? Most important one: What is the way to communicate with the device? ex: Read device address, set register, read/write data or do I miss something? Thanks for your help.
  • tdlivingstdlivings Posts: 437
    edited 2014-03-11 12:57
    If you check out Sparkfun they have a similar radio and Ardunio code which would be in C that you can look over
    https://www.sparkfun.com/products/10663

    Tom

    E
    dit I did a project in Spin using that radio, you can also look at
    http://forums.parallax.com/showthread.php/141657-Sparkfun-Si4703-FM-Radio?highlight=radio
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-11 13:17
    According to the code I have the address is 0x40 and 0x42.
    1) The RDA5807SS has two I2C Device Addresses,
    
        I2CAddr_Continue = 100000_0 --> Continue write/read data to/from device's registers without sending the Registers Name
        I2CAddr_Standard = 100001_0 --> Standard write/read data to/from device's registers 
    
    
    

    0x40 shift one to the right is 0x20.

    The last bit of the address indicates if the device is to be read from or written to. If you leave off this bit (by shifting one to the right) then the addresses are the same (but I don't know if this is how your documentation come up with 0x20).

    My short experience using I2C with other microcontrollers left me rather confused about addresses. When I watched the I2C transaction with my logic analyzer (LA), it gave a different address than indicated within the source code (Arduino code). When I translated the code to Spin, I had to use the number read from the LA rather than using the address from the source code.

    I'm still puzzled about how different microcontrollers define and use I2C addresses.
  • davi_cdavi_c Posts: 3
    edited 2014-03-12 05:11
    Thank Tom and Duane. I'll try the link from Tom's post in the next couple of days and let you know later.
    David.
  • tdlivingstdlivings Posts: 437
    edited 2014-03-12 11:12
    Duane
    The Ardunio I2C lib only wants the 7bit device address ignoring the read write bit.
    It handles the read write bit internally. Others will have two
    separate 8 bit addresses one for read and one for write with the same 7 bits and the read write bit attached.
    A logic analyzer will always see the 8 bit version as expected. I2C does not care how humans want to define it
    just wants a 7bit device address and a 1 bit read or write bit.

    Data sheets use both methods some give a 7bit device address and some the two read and write addresses
    with the devices 7bit address and a read write bit tacked on. I bet there is even
    a device data sheet that uses both ways in different parts of the data sheet.

    Tom
Sign In or Register to comment.