Giter VIP home page Giter VIP logo

pic12f675-tm1637-display-code's Introduction

PIC12F675-TM1637-Display-Code

Demo C code which drives a TM1637 display using a PIC 12F675, compiles using MPLAB XC8 compiler A port of part of copyright code written by Dan C: https://github.com/electro-dan/PIC12F_TM1637_Thermometer which was originally compiled with the Boost C compiler. Uploaded with original author permission. Developed and compiled using the MPLAB X IDE v6.05. All code is in a single file, no header dependencies apart from the MPLAB xc.h. It should port to other compilers pretty easily, I have tried to minimise MPLAB XC8 dependencies which are mainly PIC register definitions and use of the MPLAB __delay inline function.

The PIC12F675 is a small chip ideal for driving commercially available TM1637 modules with minimal additional board footprint or additional components. As coded timing is using the on-chip oscillator. With appropriate adaptation it should be possible to drive displays using more than the 4 digits as were used for test purposes. Memory resources used by the C code approximate to 50% for display only though this allows some headroom to add for example ADC code for analogue inputs or I2C code for interface with other chips.

My most recent commit added example code for PIC12F675 analogue input and TM1637 display of the data. A 0-5V signal is converted using the PIC's 10 bit ADC and displayed on the TM1637 rounded to 3 digits. Integer maths is used for scaling of the raw ADC data, floating point is not really an option on this chip. Note that rounding adds overhead and as coded in C my ADC example code uses approx 90% of program memory with basic free XC8. I am sure the code could be further optimised or the rounding code simply removed if not needed.

Beware of in circuit programming issues coding for this small PIC given that the programming pins are almost inevitably shared with inputs or other circuit components. In particular connecting AN0/ICSPDAT to the Vcc power rail via a fairly low impedance will cause programmer errors. This happens if you use a lowish value potentiometer as an input voltage source for example. Failed programming can trash the PICs calibration data permanently, you have been warned! Isolate ICSPDAT and ICSPCLK from the power rails when programming.

Note that the TM1637 module used can be made to communicate faster than the speed used in the demo code, see my description in the capacitor removal .pdf file

For a port of code here to the more powerful PIC12F1840 see also my repository: https://github.com/SteveMicroCode/PIC-12F1840-Demo-Code

Steve 6/2023

pic12f675-tm1637-display-code's People

Contributors

stevemicrocode avatar

Stargazers

 avatar

Watchers

 avatar

pic12f675-tm1637-display-code's Issues

Solution Tip: PICKIT3 Failing to Burn PIC16F1938 (using TM1637 display)

Error:

Address: 0 Expected Value: a01 Received Value: 0
Failed to program device

Solution: if the display lights up during PIC programming, this error may occur.

  • Make sure the display will not light up as soon as the PIC starts.
    • Add at the beginning of the PIC initialization the instruction to turn off the display and wait a few milliseconds (I left 1 second).

Related:

The post below mentions the PGM pin, but on this PIC I didn't find this pin, so after reviewing the PGD and PGC pins, all that was left was the display.

https://forum.microchip.com/s/topic/a5C3l000000MZqfEAG/t367861?page=2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.