i have a GE864-GPS module and i am attmeping to program a MAC9867 audio codec. It works using the following AT commands however it seems to fail when i try to program via python.
I tried to replicate this in python using the IIC module however it fails when it tries to write. I suspect it has something to do with the slave write and read addresses. Any help would be greatly apprecated.
Thanks,
Python code….
I2C_SDA = 8 # GPIO for SDA pin
I2C_SCL = 7 # GPIO for SCL pin
I2C_WR = 0x30 # MAX9867 slave write address
I2C_RD = 0x31 # MAX9867 slave read address
LOG.info("creating IIC bus")
write = IIC.new(I2C_SDA, I2C_SCL, I2C_WR)
#set DVI interface
LOG.info("setting DVI")
MDM.send("AT#DVI=1,1,0r", 2)
success, ans = SMS.waitForOK(5)
if success:
LOG.info("doing write init")
BUSstatus = write.init()
if BUSstatus == -1:
return -1
# set the codec registers start at 4
# see included codec config documentation for explanation
LOG.info("Doing register config")
try:
if write.readwrite(‘x04x00x10x10x00xA4x0Ax33x00x00x33x0Cx0Cx09x09x24x24x40x00x60’, 0) == -1:
LOG.error("register write failed")
return -1
except Exception,e:
LOG.info(e)
LOG.info("Register config done")
# turning on codec
LOG.info("turning on codec")
if write.readwrite(‘x17x8A’, 0) == -1:
LOG.error("power on failed")
return -1
return 0
Hi Robi,
I believe the problem could be in how the register address has to be write..
In the py module readwrite the addr wrote via the IIC.new function is automatically shifted to left by 1 and theLSB bit isset to 0 or 1 to perform a read or a write.
So try to change the code as below:
I2C_WR = 0x18 # MAX9867 address shifted right by 1
We use cookies to enhance your browsing experience and help us improve our websites. To improve our website, we carefully select third parties that use cookies to allow us to serve specific content and achieve the purposes set out in our cookie policy. For more information on how to make adjustments through your browser to the cookies being used on your device, please click Find Out More link. By closing this banner or continuing to browse our website, you agree to our use of such cookies. FIND OUT MORE
Greetings,
i have a GE864-GPS module and i am attmeping to program a MAC9867 audio codec. It works using the following AT commands however it seems to fail when i try to program via python.
Here is the AT commands that work.
AT#I2CWR=X,Y,30,4,19
> 00101000A40A330000330C0C09092424400060<ctrlZ>
OK
and
AT#I2CWR=X,Y,30,17,1
> 8A<ctrlZ>
OK
I tried to replicate this in python using the IIC module however it fails when it tries to write. I suspect it has something to do with the slave write and read addresses. Any help would be greatly apprecated.
Thanks,
Python code….
return 0
Hi Robi,
I believe the problem could be in how the register address has to be write..
In the py module readwrite the addr wrote via the IIC.new function is automatically shifted to left by 1 and theLSB bit isset to 0 or 1 to perform a read or a write.
So try to change the code as below:
I2C_WR = 0x18 # MAX9867 address shifted right by 1