ToniG - 2022-05-22

I had a need for additional functionality with TM1637 library (read key/buttons, 2 values on 1 display, remap digits etc... ) so I made a new include based on existing.
During testing some problems, I noticed an anomaly on the DIO where TM & Micro were fighting for about half CLK . It occurs at the start of ACK & only when the last data bit is a 1 (as is with C0 address command). This does not stop communication but better to fix it. I am testing with 12F683 device.
TM asserts the pin(ACK) when the 8th clock is set low so DIO need to be released by micro asap.
If someone can test this on some other micro would be good.
It is an easy fix, just move the 'dir TM1637_DIO in' before the delay from 'set TM1637_CLK off'

In 'TM1637 Ack issue.png' the issue is shown between cursors.

  From:
    'wait for ACK
    set TM1637_CLK off
    wait 50 us
    dir TM1637_DIO in
    set TM1637_CLK on
    wait 50 us
    if TM1637_DIO = 0 then
    dir TM1637_DIO out
    end if
    set TM1637_CLK off
  To:
        'wait for ACK
    set TM1637_CLK off
    dir TM1637_DIO in
    wait 50 us
    set TM1637_CLK on
    wait 50 us
    if TM1637_DIO = 0 then
    dir TM1637_DIO out
    end if
    set TM1637_CLK off

Ack code from my driver... I also add the end delay to better define the Stop sequence.

Sub TM1637_Ack   'Ack sequence for TM1637 (just another bit clk)
'    Ack_ok = 0
    Set TM1637_CLK 0  '< TM assert DIO here
     Dir TM1637_DIO in
     Wait TM_Dly us
    Set TM1637_CLK 1
    Wait TM_Dly us
'    If TM1637_DIO = 0 then Ack_ok = 1
     Dir TM1637_DIO out
    Set TM1637_CLK 0  '< TM release DIO here
    Wait TM_Dly us
End Sub
 

Last edit: ToniG 2022-05-22