I2C Beginner Problems
I Try to get running a Comunication between a Propeller Quickstart Board with an Switching Mode Power Supply (SMPS) via I2C.
I am not anprofessional programmer so these question might be silly or obvious to solve.... Sorry for that in adavance.
* Cotek AE-800 (Spec. sheet; Comm. Protocol)
* Adress (zero): 1010_000_R/W
* @PSU Connected at pin 19 (SCL) and Pin 20 (SDA) Pullup Resistor to +5V Aux via 2,2kOhm
* @QuickstartBoard SDA Cable to 1 (P0) SCL Cable to Pin 2 (P1) (on 28/29 i got propblems by flashing the board)
* Driver: jm_I2C
Get the SMPS into I2C Mode. And Setting a Voltage
Due to Com Protocol, I can directly write to the control register (0x7C) then the LED should turn from green to orange.
My first attempt was to Read / Write to Bit 7 of Addres 0x7C [0x7C.7]
So, I took the code of JonnyMc EEProm Demo. and changed a bit:
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 PSU_SCL = 1 'pin 1 for second SCL -> EEprom not accacable PSU_SDA = 0 'pin 2 for second SDA -> EEprom not accacable PSU_write = $A0 '10100000 PSU_read = $A1 '10100001 CLS = 16 ' Parallax Serial Terminal constants CR = 13 VAR long c OBJ i2c : "jm_i2c" pst : "Parallax Serial Terminal"~~~~ PUB main pst.Start(115_200) pst.Clear i2c.setupx(PSU_SCL, PSU_SDA) waitcnt(clkfreq/16 + cnt) c := 9 repeat c := rd_byte($7C) pst.Dec(c) pst.str(string(CR)) waitcnt(clkfreq/16 + cnt) pub rd_byte(address) | value i2c.start i2c.write($A0) 'adress of the PSU Writing mode i2c.write(address) i2c.start i2c.write($A1) 'adress of the PSU reading mode value := i2c.read(i2c#NAK) i2c.stop return value pub write_byte(address) i2c.start i2c.write($A0) 'adress of the PSU Writing mode i2c.write(address) i2c.write($01) i2c.stop~~~~
I never get a feedback to the serial monitor. I found the rd_byte function never gets over I2C.stop, so no Return happens.
i Would apreciate anny Ideas and Help on this issue.
*edit: delted nonsens