• Thanks! Those X9C103 look really interesting - a very neat way to control volume!

    The code you've got there looks good - one thing to watch out for is that digitalPulse is asyncronous - so:

    digitalWrite(LED1, 1);
    digitalPulse(LED2, 1,100);
    digitalWrite(LED1, 0);
    

    Will turn LED1 on, then LED2 on, then LED1 off, then LED2 off 100ms later. I think for your X9C103 it might mean that .up().up() will fail - so I'd consider just using two digitalWrites to do the pulses to make things easier.

    Let us know if you have any questions about interfacing to the si4703 - I'm more than happy to help - it'd be really fun to see an Espruino powered radio :)

  • Okay, I've been breaking my head over this. There is a datasheet and an extensive programming guide available, but both assume you are able to interface with the si4703 :/

    I'm using the Arduino-sketch as a guide line:

    	function si4703 ( option ) {
    		this.addr  = 0x10;
    		this.reset_pin = option.res;
    		this.data_pin  = option.dat;
    		this.clock_pin = option.clk;
    		this.sen_pin   = option.sen;
    		this.registers = new Uint16Array(16);
    	}
    
    	si4703.prototype.init = function () {
    		pinMode(this.reset_pin, 'output');
    		digitalWrite( this.reset_pin, false );
    
    		pinMode(this.data_pin, 'output');
    		digitalWrite( this.data_pin, false );
    
    		digitalWrite( this.reset_pin, true );
    
    		this.i2c = I2C1;
    		this.i2c.setup( { scl: this.clock_pin, sda: this.data_pin } );
    
    		this.readReg();
    
    		this.registers[ 0x02 ] = 0x4001; // enable IC
    		this.registers[ 0x07 ] = 0x8100; // enable oscillator
    
    		this.writeReg();
    
    		this.readReg();
    	};
    
    	si4703.prototype.readReg = function () {
    		this.i2c.writeTo( this.addr, 0 );
    		data = this.i2c.readFrom( this.addr, 32 );
    
    		for( var x=0x0A; ; x++ )
    		{
    			if( x == 0x10 ) x=0;
    			this.registers[x] = data[x] << 8;
    			this.registers[x] |= data[x];
    			if( x == 0x09 ) break;
    		}
    
    		console.log( this.registers );
    	};
    
    	si4703.prototype.writeReg = function () {
    		for( var i in this.registers )
    		{
    			if( i > 0x02 )
    				this.i2c.writeTo( this.addr, i, this.registers[i] );
    		}
    	};
    

    So,the init-method should read the registers, update a few things (mainly the ENABLE-bit), and read the registers again. However, there is no change in the actual registers (first line is the output at startup, second line is after attempting to write the new values):

    new Uint16Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4626, 16962, 2056, 0])
    new Uint16Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4626, 16962, 2056, 0])
    

    What am I missing?

About

Avatar for Gordon @Gordon started