Announcement

Collapse
No announcement yet.

Using RDF5807 over I2C on uLCD-43DT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using RDF5807 over I2C on uLCD-43DT

    Hi there everybody,

    I am desperately trying to make my uLCD-43DT display run a RDA5807 FM tuner chip via I2C.
    There is this Arduino sketch I tried to convert to 4DGL but some how I can not bring it to work. The Arduinocode however does work on the Arduino. Don´t worry, the Chip is 3.3V Logic. I am using a logic level converter if I use Arduino.

    Here is the Arduino code:
    Code:
    #include <Wire.h>
    uint16_t channel = 191;
    /* address of the RDA5807 on two wire bus */
    #define RDA5807M_ADDRESS 0b0010000 // 0x10
    
    #define BOOT_CONFIG_LEN 12
    #define TUNE_CONFIG_LEN 4
    
    uint8_t boot_config[] = {
    0b11000000, 0b00000011, 0b00000000, 0b00000000, 0b00001010, 0b00000000, 0b10001000, 0b00001111, 0b00000000, 0b00000000,0b01000010, 0b00000010
    };
    
    /* After reset, we can tune the device
    * We only need program the first 4 bytes in order to do this
    */
    uint8_t tune_config[] = {
    /* register 0x02 */
    0b11000000,
    0b00000001,
    (channel >> 2),
    ((channel & 0b11) << 6 ) | 0b00010000
    };
    
    
    
    void setup()
    {
    /* Conect to RDA5807M FM Tuner: */
    Wire.begin(); /* join i2c bus (address optional for master) */
    
    Wire.beginTransmission(RDA5807M_ADDRESS); /* Sending boot configuration (device should reset) */
    Wire.write(boot_config, BOOT_CONFIG_LEN); /* Write the boot configuration bytes to the RDA5807M */
    Wire.endTransmission();
    
    Wire.beginTransmission(RDA5807M_ADDRESS); /* Tuning to channel */
    Wire.write(tune_config, TUNE_CONFIG_LEN); /* Write the tuning configuration bytes to the RDA5807M */
    Wire.endTransmission();
    
    }//setup end
    
    void loop()
    {
    
    }
    My attempt on converting this to the Diablo 16 looks like this:
    Code:
    #platform "uLCD-43DT"
    
    #inherit "4DGL_16bitColours.fnc"
    
    #constant RDA5807M_ADDRESS 0x10
    #constant BOOT_CONFIG_LEN 12
    #constant TUNE_CONFIG_LEN 4
    var x:=0;
    var boot_config[] := [
    0b10000000,0b00001011,0b00000000,0b00000000,0b00001010,0b00000000,0b10001000,0b00001111,0b00000000,0b00000000,0b01000010,0b00000010
    ];
    var channel := 191;
    
    var tune_config[] := [
    0b10000011,
    0b00001001,
    (channel >> 2),
    ((channel & 0b11) << 6 ) | 0b00010000
    ];
    
    func main()
    gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change
    
    gfx_MoveTo(0, 20);
    print("Radio boot\n") ;
    I2C1_Open(I2C_SLOW,PA10,PA11);
    
    I2C1_Idle();
    I2C1_Start();// Generate Start condition
    I2C1_Write(RDA5807M_ADDRESS<<1|0);
    I2C1_Putn(boot_config, BOOT_CONFIG_LEN);
    I2C1_AckStatus();
    I2C1_Stop(); // finished with bus
    print("\n");
    
    pause(450);
    
    print("Setting Channel\n") ; // replace with your code
    
    I2C1_Idle();
    I2C1_Start(); // Generate Start condition
    I2C1_Write(RDA5807M_ADDRESS<<1|0);// send slave address, R/W bit is 0;
    I2C1_Putn(tune_config,TUNE_CONFIG_LEN);
    I2C1_AckStatus();
    I2C1_Stop(); // finished with bus
    gfx_Cls();
    gfx_MoveTo(0, 20);
    print("Done\n") ; // replace with your code
    
    repeat
    
    forever
    
    endfunc
    Can you help me out? I really am at my wit´s end. It will be very much appreciated.


    Looking forward to your ideas.



    Greets Xenorollmops

  • #2
    Sorry, I don't have one of these to test, so I can't be sure of my suggestions, but anyway.

    Do you definitely have pullups on the SCL + SDA pins?

    I think the main problem is with your arrays, ram arrays are always arrays of 16 bit integers, wheres you want to write an array of bytes.

    Try replacing your arrays and channel variable with
    Code:
    #constant channel 191
    #DATA
      byte boot_config 0b10000000,0b00001011,0b00000000,0b00000000,0b00001010,0b00000000,0b10001000,0b00001111,0b00000000,0 b00000000,0b01000010,0b00000010
      byte tune_config 0b10000011,0b00001001,(channel >> 2),((channel & 0b11) << 6 ) | 0b00010000
    #END
    If that works, read https://docs.4dsystems.com.au/app-note/4D-AN-00047 to see how you can set up non constant commands
    Mark

    Comment

    Working...
    X