
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Hello, I have already looked into this forum to see if anybody had troubles reading the steps taken but did not find anything. It looks like that basic++ is a mix of basic and c++, I looked at the code but I donÂ’t like what I see, the code does not take I2C clock stretching into consideration, this is really important if you are using micro controller based slaves, my code does. Also, to make an i2c port go HIGH you do not sda = 1 or sda = on, I think this is not good, you must deact sda, the pullup resistor will do the rest. I want to try something else, replace the code with the code below, and let me know if this works. Greetings, H.J. Windt #read_motor_steps_taken if motor_selection > 1 then print "Cant read both motors at the same time!!" if motor_selection > 1 then goto start gosub start_i2c i2c_byte = &h56 : gosub write_byte_i2c i2c_byte = 10 : gosub write_byte_i2c i2c_byte = 13 : gosub write_byte_i2c i2c_byte = motor_selection : gosub write_byte_i2c gosub stop_i2c if i2c_nack then goto pass_read gosub start_i2c i2c_byte = &h57 : gosub write_byte_i2c gosub read_byte_i2c : low_word = i2c_byte gosub read_byte_i2c : low_word = i2c_byte * 256 + low_word gosub read_byte_i2c : high_word = i2c_byte gosub read_last_byte_i2c : high_word = i2c_byte * 256 + high_word gosub stop_i2c #pass_read if i2c_nack_count > 18 then goto no_ack_from_i2c_device if i2c_nack then goto read_motor_steps_taken print"HIGH word = ";high_word;" Low word = ";low_word goto start |
| Antwort schreiben |