Soft-I2C


#1

Hellow,

I’ve got a time-problem with my Q2686.
I have to implement a soft I2C on the Q2686 because of my Li+ Battery Monitor (Maxim DS2762).
The DS2762 has a one wire communication (Dallas 1-Wire) with a time slot of 60us…

With Q2686 i can toggle with 23us, but the change of direction has a duration of 150us because of the slow adl_ioSetDirection-Function

Does anybody have an idea of fixing that problem?

My actual code:

adl_ioDefs_t gpio = GPIO_PIO;
adl_ioDefs_t gpioc = gpio  | ADL_IO_GPIO | ADL_IO_GPI | ADL_IO_DIR_IN ;
adl_ioDefs_t gpioo =  gpio  | ADL_IO_DIR_OUT;
adl_ioDefs_t gpioi =  gpio | ADL_IO_DIR_IN;

pioHandle = adl_ioSubscribe(1, &gpioc , 0, 0, 0) ;

//Now, it's an input (has an extern Pull-Up)

adl_ioSetDirection(pioHandle,1,&gpioo);

//Now it's a output

adl_ioWriteSingle(pioHandle, &gpio, FALSE); //Write something, should take 60us

adl_ioSetDirection(pioHandle,1,&gpioi );  //Change shouldn't take more than 20us

//Now it's an input

returnwert=adl_ioReadSingle (pioHandle, &gpio ); //Read the answer

#2

I’m pretty sure that it is impossible to do software 1-wire on q2686. But I think that it is possible to avoid switching the direction by using a multiplexor. You can connect one GPIO for reading and one GPIO for writing to the external IC. Now you can select the line with the third GPIO.
Better solution is to use dedicated IC for 1-wire communication. There are SPI to 1-wire translators.


#3

Ok, thank you, so the translator is going to be the soloution.


#4

Hiya,

I can recommend using the Maxim DS2482-100 single channel 1-wire bridge - I’ve got it running on a project of mine.

Note that this chip is I2C, NOT SPI - Maxim haven’t got any SPI to 1-Wire bridge chips.

Also, watch your voltage levels on the Q26. The I2C port on the Q26 is Open Drain, 3V3 tolerant - so make sure that you use the right pull-ups for the I2C bus.

Maxim also make a UART to 1-Wire bridge - this may be easier for you to use/interface.

ciao, Dave