I2C and Si570 Synthesiser
g3cwi
Posts: 262
Hi there
I am starting to get to grips with I2C to program an Si570 synthesiser. I can see the Si570 device on the I2C bus and get an ack from it. However, I am having trouble reading from it. I am using Javalin's Object. I suspect I am feeding the register addresses wrongly. Any ideas? BTW I am new to this so use simple words! Thanks.
Debug o/p:
I2C Demo (v2)!
Scanning I2C Bus....
Scan Addr : %10100000, ACK
Scan Addr : %10101010, ACK
i2cScan found 2 devices!
EEPROM Present
Si570 Present
Si570 DEMO
Read Si570 Location=00007, data byte=00002
Read Si570 Location=00008, data byte=00002
Read Si570 Location=00009, data byte=00002
Read Si570 Location=00010, data byte=00002
Read Si570 Location=00011, data byte=00002
Read Si570 Location=00012, data byte=00002
Read Si570 Location=00013, data byte=00002
Read Si570 Location=00014, data byte=00002
Read Si570 Location=00015, data byte=00002
Read Si570 Location=00016, data byte=00002
Read Si570 Location=00017, data byte=00002
Read Si570 Location=00018, data byte=00002
Si570 demo done.
I am starting to get to grips with I2C to program an Si570 synthesiser. I can see the Si570 device on the I2C bus and get an ack from it. However, I am having trouble reading from it. I am using Javalin's Object. I suspect I am feeding the register addresses wrongly. Any ideas? BTW I am new to this so use simple words! Thanks.
Debug o/p:
I2C Demo (v2)!
Scanning I2C Bus....
Scan Addr : %10100000, ACK
Scan Addr : %10101010, ACK
i2cScan found 2 devices!
EEPROM Present
Si570 Present
Si570 DEMO
Read Si570 Location=00007, data byte=00002
Read Si570 Location=00008, data byte=00002
Read Si570 Location=00009, data byte=00002
Read Si570 Location=00010, data byte=00002
Read Si570 Location=00011, data byte=00002
Read Si570 Location=00012, data byte=00002
Read Si570 Location=00013, data byte=00002
Read Si570 Location=00014, data byte=00002
Read Si570 Location=00015, data byte=00002
Read Si570 Location=00016, data byte=00002
Read Si570 Location=00017, data byte=00002
Read Si570 Location=00018, data byte=00002
Si570 demo done.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 _stack = 50 i2cSCL = 28 i2cSDA = 29 EEPROMAddr = %1010_0000 Si570Addr = %1010_1010 'AA ' EEPROM data base address - i.e 32K (assumes a 64kb eeprom installed!!) EEPROM_Base = $8000 ' debug - USE onboard pins pcDebugRX = 31 pcDebugTX = 30 ' serial baud rates pcDebugBaud = 115200 VAR long i2cAddress, i2cSlaveCounter OBJ i2cObject : "basic_i2c_driver" 'Si570Object : "Si570Object" debug : "Debug_PC" pub Start ' start the PC debug object debug.startx(pcDebugRX,pcDebugTX,pcDebugBaud) ' setup i2cobject i2cObject.Initialize(i2cSCL) ' pause 5 seconds repeat 20 debug.putc(".") waitcnt((clkfreq/6)+cnt) debug.putc(13) ' i2c state debug.strln(string("I2C Demo (v2)!")) 'demo the i2c scan i2cScan waitcnt(clkfreq +cnt) repeat ' demo the EEPROM if i2cObject.devicePresent(i2cSCL,eepromAddr) == true debug.strln(string("EEPROM Present")) 'EEPROM_Demo else debug.strln(string("EEPROM Missing")) waitcnt(clkfreq+cnt) ' demo the Si570 Oscillator if i2cObject.devicePresent(i2cSCL,Si570addr) == true debug.strln(string("Si570 Present")) Si570_Demo else debug.strln(string("Si570 Missing")) waitcnt(clkfreq+cnt) PRI EEPROM_Demo | eepromData, eepromLocation, ackbit ' demo the i2c Serial EEPROM (Microchip's 24LC512 (64kb)) debug.strln(string("EEPROM DEMO")) ' ***** EEPROM read/Write example ***** eepromLocation := EEPROM_Base eepromData := 0 repeat 5 ' write long eepromData += 100 i2cObject.WriteLong(i2cSCL, EEPROMAddr, eepromLocation, eepromData) ' read long eepromData :=0 eepromData := i2cObject.ReadLong(i2cSCL, EEPROMAddr, eepromLocation) ' debug debug.str(string("Read Location=")) debug.decx(eepromLocation,5) debug.str(string(", data=")) debug.decx(eepromData,5) debug.putc(13) ' next eepromLocation +=4 ' slowit waitcnt(clkfreq/20 + cnt) ' done debug.strln(string("EEPROM demo done.")) PRI Si570_Demo | Si570Data, Si570Location, ackbit ' demo the i2c Serial Si570 (Microchip's 24LC512 (64kb)) debug.strln(string("Si570 DEMO")) ' ***** Si570 read/Write example ***** Si570Location := 7 Si570Data := 0 repeat 12 Si570Data :=0 Si570Data := i2cObject.ReadByte(i2cSCL, Si570Addr, Si570Location) ' debug debug.str(string("Read Si570 Location=")) debug.decx(Si570Location,5) debug.str(string(", data byte=")) debug.decx(Si570Data,5) debug.putc(13) ' next Si570Location +=1 ' slowit waitcnt(clkfreq/10 + cnt) ' done debug.strln(string("Si570 demo done.")) Repeat 'Wait here PRI i2cScan | value, ackbit ' Scan the I2C Bus and debug the LCD debug.strln(string("Scanning I2C Bus....")) ' initialize variables i2cSlaveCounter := 0 ' i2c Scan - scans all the address's on the bus ' sends the address byte and listens for the device to ACK (hold the SDA low) repeat i2cAddress from 0 to 127 value := i2cAddress << 1 | 0 ackbit := i2cObject.devicePresent(i2cSCL,value) if ackbit==false 'debug.str(string("NAK")) else ' show the scan debug.str(string("Scan Addr : %")) debug.bin(value,8) debug.str(string(", ACK")) ' the device has set the ACK bit i2cSlaveCounter ++ waitcnt(clkfreq/20+cnt) debug.putc(13) ' slow the scan so we can read it. waitcnt(clkfreq/40 + cnt) ' update the counter debug.str(string("i2cScan found ")) debug.dec(i2cSlaveCounter) debug.strln(string(" devices!"))
Comments
Regards
Richard
G3CWI
BTW Have you seen Phils work on demodulation of RF ? He has done some great work with the prop in this arena.
I am working on "relative" frequency addressing of the chip. This seems to be pretty good for the 3500ppm range and also makes the whole control of the chip really easy (once the initial maths are done). I have settled on 50Hz steps for my application, this just requires a simple add. The hard way involves 38 bit maths plus range selection for N1 and HS_DIV which would be too much like hard work!
I have looked at Phil's work although I remain to be convinced that the Propellor is an appropriate platform for serious RF DSP (hard hat on). For much the same reasons, I am going down the AD9851/Si570 route for RF generation. I know the Propellor can do it but... I want to play to the strengths of the Prop platform.
Cheers
Richard
G3CWI
Ray
VK2ZTZ