Menu

TM1637 6 digit with PIC16f877A

AB
2025-05-13
2025-05-24
<< < 1 2 3 > >> (Page 2 of 3)
  • AB

    AB - 2025-05-14

    ok - a bit more information.
    I have moved back to the 16f628a to remove any issues with crystals/clocks etc
    Attached is the oscilloscope traces from the arduino which works perfectly.
    I can't capture the waveform for the 16f628a as while there is activity, it looks nothing like whats in this picture and i can't get it to trigger so i can take the picture.
    The logic checker shows changing in levels but the waveform is vastly different.
    Its well above my pay grade as to what is going on as i have tried all the suggestions proposed plus others i have dreamed up
    As ever - any wise suggestions would be greatly appreciated

     
    • AB

      AB - 2025-05-16

      and for anobium - here is the result form the test you asked ot run

       
    • AB

      AB - 2025-05-16

      and the files

       
  • Roger Jönsson

    Roger Jönsson - 2025-05-14

    While trying to get my 4 digit version to run (solved by adding a delay before the first numbers sent) I read about someone who had received a module where they had mounted 100nF capacitors on the inputs (instead of 100pF). Your waveform does look slow. I have no idea what that is about but it could be worth looking into.

     
  • AB

    AB - 2025-05-14

    but the display works fine when using an arduino.

     
  • Roger Jönsson

    Roger Jönsson - 2025-05-14

    Maybe the arduino can output just slightly more current to get the signal through in time?

     
  • Roger Jönsson

    Roger Jönsson - 2025-05-14

    Maybe you need a capacitor between VCC and VDD close to the PIC?

     
  • AB

    AB - 2025-05-14

    the signals are totally different even with the display disconnected and the oscilloscope won't add any resistance either
    I am suspecting that the library is not compatible with microchip ic's i am trying to use.

    i am about to give up

     
  • Roger Jönsson

    Roger Jönsson - 2025-05-14

    The waveform looks to me like the PIC can't supply enough current. Not even for the capacitance of the cable connected to its outputs? Do you have a capacitor between VCC and VDD close to the PIC?

     
  • HackInBlack

    HackInBlack - 2025-05-14

    I compiled the PIC version, burned it to a 16F877A with a 4Mhz xtal plonked it into an old MIKROe easyPIC v2 board, and scoped its RB6 (data) and 7 (clock) pins... nothing but random noise on the pins...wha? little wonder it doesn't appear to run
    a quick sanity check using a barebones blinky program showed normal scope traces

     

    Last edit: HackInBlack 2025-05-14
  • Anobium

    Anobium - 2025-05-14

    Let us rule out compiler. Can you post you GCB and your ASM file ( generated after compilation ). Let me have look.

    Evan

     
  • HackInBlack

    HackInBlack - 2025-05-14

    here's the original downloaded files for 16F877A @20Mhz

     

    Last edit: HackInBlack 2025-05-14
    • Anobium

      Anobium - 2025-05-14

      Nothing to see in the ASM. The ASM is the same as using a 2020 version of the compiler. That rules out the DAT file and library ( in terms of the ASM generated ).

      My thoughts. We know this works on a MEGA328P. ( correct ? ). I have checked the original code and that was MEGA328P.

      So, I looked at the detail in the library. Cannot see any major issue.


      Test this. This should toggle the the CLK and DIO lines. Does it?

      #chip 16F877A, 4
      #include <TM1637_6d.h>
      
      
        #define TM1637_CLK Portb.7
        #define TM1637_DIO Portb.6
      
        Do
      
          TM1637_Start
      
        Loop
      

      The library sub is this. ON and OFF.

      sub TM1637_Start
          set TM1637_CLK on
          set TM1637_DIO on
          wait 50 us
          set TM1637_DIO off
          set TM1637_CLK off
          wait 50 us
      end sub
      

      So, what does the scope see?

       
  • AB

    AB - 2025-05-14

    the scope sees a small jump in each output - but nothing clocks after that. Just 2 flat lines

     
  • AB

    AB - 2025-05-14

    here is the asm file and gcb file

     
  • HackInBlack

    HackInBlack - 2025-05-14

    the testfile works on my lash-up hardware; scoped at 5v/100us per division

     

    Last edit: HackInBlack 2025-05-14
  • Anobium

    Anobium - 2025-05-15

    A scope of the program shows the same as @HackInBlack.

    My guess. This looks like a look like you have the LCD connected to the same port as the programmer and the programmer is holding the lines.

    Evan


    Further analysis.

    #chip 16F877A
    #include <TM1637_6d.h>
    
    
      #define TM1637_CLK Portb.7
      #define TM1637_DIO Portb.6
    
      Do
    
        TM1637_Start
    
      Loop
    

    is NOT

    #chip 16F877A
    #include <TM1637_6d.h>
    
    
      #define TM1637_CLK Portb.7
      #define TM1637_DIO Portb.6
    
      Do
    
        TM1637_Start
    
      Loop
    'The library sub is this. ON and OFF.
    sub TM1637_Start
        set TM1637_CLK on
        set TM1637_DIO on
        wait 50 us
        set TM1637_DIO off
        set TM1637_CLK off
        wait 50 us
    end sub
    

    The second code is the program provide. Moving the TM1637_Start sub from the library to the main program would prevent the library from handling the init().

    The first program works as GCBASIC analysed the program, and, set the PORTs to OUTputs. The library init() was not executed as there was no reference ( usage ) within the library.

     

    Last edit: Anobium 2025-05-15
  • HackInBlack

    HackInBlack - 2025-05-15

    i've altered the original demo program to use portD instead of portB...now it works! give this a try:-

     

    Last edit: HackInBlack 2025-05-15
  • AB

    AB - 2025-05-15

    which fuse settings did you use?

     
    • Anobium

      Anobium - 2025-05-15

      The config ( not fuse ) is determined in the GCB source ( which is none...), So, it is the default config for that chip.

      To see the default with out wading into the ASM, open PICINFO, select the CHIP and PICINFO will display the default config.

       
  • HackInBlack

    HackInBlack - 2025-05-15

    here's the logic view

     
  • HackInBlack

    HackInBlack - 2025-05-15

    i used a 4Mhz clock;as the chip is a 4mhz max. part

     

    Last edit: HackInBlack 2025-05-15
  • AB

    AB - 2025-05-16

    ok - here is my latest progress.
    When i use a 90s8535 - tm1637 works perfectly
    When i use the 16f677a - the display is still blank - although i can see activity on the oscilloscope.

    So between the 2 programmes - the only difference is the chip and the port definitions
    The circuit is the same - using a 4MHz crystal.

    For anobium - here is the result from the oscilloscope for the test you asked to run.

     
  • AB

    AB - 2025-05-16

    and the test anobium asked for - using the 16f877a

     
  • AB

    AB - 2025-05-16

    and the test anobium asked for - using the 16f877a

     
<< < 1 2 3 > >> (Page 2 of 3)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.