what is the DDRA for DIO/CLK Pins ?

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

What is the correct setting of the DDRA for DIO/CLK pins when I use TM1637 4 segment Display ?

 

This topic has a solution.
Last Edited: Sat. Apr 9, 2022 - 03:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It depends on library you are using. Full capability of TM1637 is both input, and output.

It means that DIO is bi-directional. However, some modules does not use it.

Look at those resistors /on schematics/, they are similar to I2C, so, to made '0' on DIO, set DDRA pin active.

As for CLK, it is all yours, but with pullup it is handy to use it as DIO pin.

 

Yet, you may not use it bi-directional, as I did:

sQMCQI_InitAll:
    sbi   PORTB, pCLK
    sbi   PORTB, pDIO
    sbi   DDRB, pCLK
    sbi   DDRB, pDIO

 

 

 

Last Edited: Thu. Apr 7, 2022 - 10:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

So how to not define as input and output. Do we have something like XX ?  

 

Or I have to use DDRB |= (1<PB2)| (1<PB3) until.....PB7

left PB0 and PB1 as undefined. 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


A good way to find out how to control something in this day and age is to find the Arduino driver for it.

 

So Google initially beings you to:

 

https://www.arduino.cc/reference...

 

That has enough clues:

 

 

to bring you to:

 

https://github.com/avishorp/TM16...

 

and hence...

 

 

You don't really have to understand everything that's going on here except to know that in Arduino pinMode() is basically setting bits in the DDR register high/low.

 

But the above shows the general approach to driving the thing.

 

What I'd actually recommend (assuming you have at least one Arduino - which I sort of assume everyone does these days) is to first wire up the display to an Arduino and actually used this library. That will prove that all your connections and power and so on are all working fine (even proves the display itself is working OK). When you are satisfied with all that you can lave the Arduino software behind and just put your own attempt at "driver" code into the board and see if you can make it work with your own software.

 

When all that works switch completely to "bare metal". Just put a CPU (clock/power) in a breadboard with the display attached and see if you can make that work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

left PB0 and PB1 as undefined. 

No you did not.  If the DDR bit is 0, it is an input.  If it is 1, it is an output.

Maybe you don't know what they are set to (which is why you should always use = when initializing registers), but the AVR certainly does!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

So, if I am using the TM1637 library. I shall left it undefined in the main. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hamisu wrote:
if I am using the TM1637 library.
What "library" are you talking about?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hamisu wrote:
left PB0 and PB1 as undefined

hamisu wrote:
So, if I am using the TM1637 library.

 

How we can discuss PB0 and PB1 without schematics or library.

If you have 2 pullup resistors in PB1/PB0 for DIO/CLK, then, yes, both pin will be initially undefined.

 

In my ASM example, they are initially high, because I do not have pullup resistors (and do not need keyboard services of TM1637).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Ya. I have a pull up resistor at PB1, PB0 not. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hamitsu,

 

you are starving us with such no-information. Please read actual forum about how to ask questions.

 

What is PB0, what is PB1. How so, they are not PA1, PA0. Send us your library, please.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

It was PB0 and PB1 because I am using ATTiny461A. The library is link is here

 

The display is working on MCU now. Anyway, thank you very much for the guidance.

 

The answer is DIO/CLK shall not be define in my main code.  It was define in the library. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 It was define in the library. 

Always check the library, first thing...Often much of the grunt work figuring things outwill be taken care of for you. Otherwise, the library should include instructions on what resources are needed and how they are configured (or what the limitations are, such as all xxx inputs must be on the same port).  Sadly, the documentation is often rather terse, or an afterthought.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Apr 9, 2022 - 04:48 PM