Hundred1906
Member
I thought I had picaxe - picaxe i2c cracked but now I am not so sure and could do with some guidance setting up a reliable link.
I am using two 20x2, one master, one slave with 4.7k current drive. Both on a pin-board within 4 cm of each other.
I have code in my Master that at one point sits in a tight loop executing SERIN to @PTR for 16 bytes input.
Many questions. Help with any would be appreciated.
I am using two 20x2, one master, one slave with 4.7k current drive. Both on a pin-board within 4 cm of each other.
1. Is there a relationship/dependancy between the clock frequencies of the Master and Slave. Ie do both need to be at the same clock speed (M32, M64, etc)?
2. From a reliability perspective what is the ideal i2c speed for the Master to use with a 20x2 Slave (Slow_ or Fast_). Assuming slow is best is I2cslow_64 the best combination?
3. Is it necessary for the Slave to use i2cflag (or interupt) or can it happily freewheel as indicated in the manual. In my case the Master is writing into a circular buffer and the Slave is reading from it (the buffer is in the Slave scratchpad) consequently there is no real need for the slave to monitor the i2cflag - or is there?
2. From a reliability perspective what is the ideal i2c speed for the Master to use with a 20x2 Slave (Slow_ or Fast_). Assuming slow is best is I2cslow_64 the best combination?
3. Is it necessary for the Slave to use i2cflag (or interupt) or can it happily freewheel as indicated in the manual. In my case the Master is writing into a circular buffer and the Slave is reading from it (the buffer is in the Slave scratchpad) consequently there is no real need for the slave to monitor the i2cflag - or is there?
I have code in my Master that at one point sits in a tight loop executing SERIN to @PTR for 16 bytes input.
Code:
ptr = RFID_start ' reset scratchpad pointer
for temp=1 to rfid_mess_length
serin [rfid_timeout,operate], b.1, comm_speed,@ptrinc
next temp
'check rfid data is framed correctly
{
ptr=RFID_start
if @ptr <> SOT then goto rfid_err
ptr=rfid_mess_length
if @ptr <> EOT then goto rfid_err
}
4. This works reliably unless the program has enabled i2c (eg hi2csetup i2cmaster, %10100000, i2cfast_16, i2cbyte) when the SERIN becomes unreliable .. even though i2c is not being used at that point. Should I be turning i2c off when not being used?
5. In which case - what sort of times are involved in turning i2c on and off?
5. In which case - what sort of times are involved in turning i2c on and off?
Many questions. Help with any would be appreciated.