Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Library to work with displays based on TM1637 (Oshonsoft Pic Basic Compiler).

DogFlu66

Member
I am attaching the library to work with the TM1637 based on the library written in C from the datasheets.
I have had several problems because the displays with TM1637 do not all work at the same speed and this is not taken into account in the examples in the datasheets. There is also a big problem with the datasheet example and that is that it does not configure the DIO line as an open collector, if this is not corrected it will be impossible to read the keyboard. After all these adventures I have been able to create a functional library. I just need to perform the keyboard reading test because I do not have any module with a keyboard until I receive the one I ordered.
Another important problem that I have had to implement is that in the "While" loop of the "I2CAskTM1637()" function (in the original I2CAsk) an exit had not been implemented due to lack of response from the DIO line, if this is not available Take into account that in the case of a breakdown or lack of response from the module, an infinite loop would be generated in the function.

Notice: Finish the library to work with a 4-digit display and a 6-digit display with a keyboard. So update to the new files (2024/04/10).
 

Attachments

  • _TM1637Library.bas
    10.1 KB · Views: 26
  • _Pic18F26K22Library.bas
    43.2 KB · Views: 26
  • _SetUpAmicus18.bas
    2.9 KB · Views: 29
  • Test LM1637_Keys.bas
    3.9 KB · Views: 28
Last edited:
When you say that works with both "fast and slow displays", note that the modules I used had a ridiculously long rise-time since they were using much larger caps than the 100pF shown in the datasheet example circuit.

If you do bit operations on the PORT register then you can run afoul of RMW effects.
That's one of the nice feature of Swordfish... if you do a PORT output operation (ie 'PORTB.1 = 1') it actual uses the LAT register for you automatically.
 
True, using C I did suffer from that problem until I realized it, however with this language I have not had that problem, I suppose I would do it internally with Swordfish.
Regarding the "NOPs" when placing those fixed values on the slow displays, the times were reduced to a delay of 30uSec. for the DIO line and a fixed delay for all (slow and fast) of 1uSec. for the CLK.

Therefore I use a fixed delay2 of 1uSec for the CLK line for slow and fast displays.
For the DIO line I use a delay1 of 1uSec for fast displays and a Delay1 = 30uSec for slow displays.
 
When I finish modifying the library with more peace of mind, I perform some more tests with the capacitors, just to clear up any doubts.

At the moment I classify them into slow and fast displays, as I said before I apply a delay of 30uSec to the DIO line for the slow ones and a delay of 1uSec for the fast ones, and for the CLK line I always apply a delay of 1uSec for fast and slow ones.
 
Last edited:

Latest threads

New Articles From Microcontroller Tips

Back
Top