Go Down

Topic: MAX6921 - need help (Read 1 time) previous topic - next topic

olof_n

Hi!

I am trying to get MAX6921 to drive my display.
http://datasheets.maximintegrated.com/en/ds/MAX6921-MAX6931.pdf

The segments is hooked up to OUT0-OUT6. Digits is connected to OUT7-OUT14.

From datasheet:
The MAX6921/MAX6931 are normally written using the following sequence:
1) Take CLK low.
2) Clock 20 bits of data in order D19 first to D0 last into DIN, observing the data setup and hold times.
3) Load the 20 output latches with a falling edge on LOAD.
LOAD can be high or low during a transmission. If LOAD is high, then the data shifted into the shift register at DIN appear at the OUT0 to OUT19 outputs.

I have tried to use shiftout and a self made "shiftout" funtion.

The output seems a bit random to me (digits lights up but not in the way I want :) )

Here is one of my code examples:

Code: [Select]

     byte dummy=0; //Just to fill out the upper 4 bits
     byte digit=1;     // Try to lit one digit

     digitalWrite(clockPin, LOW);
     digitalWrite(loadPin, LOW);
     shiftOut(dataPin, clockPin, MSBFIRST, dummy);
     shiftOut(dataPin, clockPin, MSBFIRST, digit);
     shiftOut(dataPin, clockPin, MSBFIRST, segFont[2]);   // segFont is a byte
 
     digitalWrite(loadPin, HIGH);       


Example 2:

Code: [Select]

void send_word(long data)
{
   digitalWrite(clockPin, LOW);
   digitalWrite(loadPin, LOW);

   for(byte i=0; i<20; i++)
   {
         if (data & (1 << i))
    {
      digitalWrite(dataPin, HIGH);
    }
    else
    {
      digitalWrite(dataPin, LOW);     
    }
      digitalWrite(clockPin, HIGH);
      digitalWrite(clockPin, LOW);
   }
   digitalWrite(loadPin, HIGH);
}



I really would like to have some working Arduino code. I have looked at the code from Adafruits "Ice Tube Clock" but do not understand it.

/Olof

fungus


3) Load the 20 output latches with a falling edge on LOAD.


You seem to have this pin backwards...

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

olof_n

Fungus, thanks for the reply.

I do not understand what "Load the 20 output latches with a falling edge on LOAD" means.
I thought that was bringing load pin LOW before shifting in the 20 bits?

/Olof

fungus


Fungus, thanks for the reply.

I do not understand what "Load the 20 output latches with a falling edge on LOAD" means.
I thought that was bringing load pin LOW before shifting in the 20 bits?


No, it means the data is latched when load goes from high to low.

So:
1) Transfer your data to the chip
2) Make LOAD pin go HIGH then LOW to latch the data
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

dhenry

A couple possibilities:

1) I didn't spend enough time to see how the device does with 20+ pulses - I think it takes the last twenty. You may want to investigate into that.
2) pulse width: the device is fairly slow so you want to make sure that there is sufficient delay there.

I would rewrite your code as such:

Code: [Select]
void send_word(long data)
{
   digitalWrite(clockPin, LOW);
   digitalWrite(loadPin, LOW);

   for(byte i=0; i<20; i++)
   {
      digitalWrite(clockPin, LOW); //data on rising edge

      if (data & (1 << i)) digitalWrite(dataPin, HIGH);
      else digitalWrite(dataPin, LOW);     

      digitalWrite(clockPin, HIGH);
   }


You may want to take a scope on the clk pin to make sure that it is close to 50%.

Go Up