ShiftOut() Max7219/AS1108 NOOB alert.

I am pretty new to the arduino but have gone through much of the LED blinking and simple control of inputs and outputs and most of it makes pretty good sense to me. My most recent project was to attempt to control a 7 segment display using a serial led driver chip similar to the Max7219. Specifically the AS1108.

My question however is not about the AS1108 so much as the some of the commands used in the ledcontrol library. Specifically ShiftOut(). I believe that I understand the basic idea of shift out and have read the description from the wiring language reference which indicates that ShiftOut allows you to send one byte of data, one bit at a time.

Since things didnt work out just hooking the led driver and using the library and associated example code, I decided to look under the hood of the led control library and figure out if the library was sending the correct commands to the AS1108. After quite a bit of review, I think that it is doing the right things however I am hung up a little on using shift out.

The thing that is puzzling me is in this application, sending commands to the AS1108, the AS1108 expects to receive 16 bit packages as the programming sequence. If ShiftOut() can only send one byte at a time, it will have to be called twice to complete a 16 bit sequence. If this is the case, will the AS1108 wait for the second 8 bit package so long as the latch has not yet gone high?

It would seem to me that the all 16 bits would need to happen in 16 consecutive clock pulses although I think I just affirmed my own ignorance.

The specific piece of code in the LEDControl Library that got me thinking about this is as follows:

void LedControl::spiTransfer(int addr, volatile byte opcode, volatile byte data) {
    //Create an array with the data to shift out
    int offset=addr*2;
    int maxbytes=maxDevices*2;

    for(int i=0;i<maxbytes;i++)
    //put our device data into the array
    //enable the line 
    //Now shift out the data 
    for(int i=maxbytes;i>0;i--)
    //latch the data onto the display

I am sure that I have overcomplicated my question but I will appreciate it if someone can confirm that the AS1108 does not need to receive all 16 bits within 16 continuous clock pulses.

The datasheet for the AS1108 can be found here:

If you are familiar with the Max7219 it appears that the AS1108 uses identical program sequences to the Max 7219.

I stil have not gotten this working but feel that I need to get this concept through my head before I can move on.

I had a quick look at the datasheet-section where the serial protocol is explained and I also get the impression that the AS1108 requires that the CS-signal is set to HIGH after 16 clock pulses. What the author of the datasheet means by or data is lost is though not clear to me.

On the MAX7219/7221 there is no such (Hardware-)restriction. Here the chip simply waits for the CS-Line going high and then it uses whatever bit-setting there is in the register. The MAX does not count clock-pulses in any way.


The two chips are pretty much identical. I have used the AS1107 many times using the libraries designed for the MAX chips without needing any modification at all.

Did you resolve this issue.. I am also a new designer. I am trying to display digits (simple counter) by using AS1108. could you please give me a sample code for AS1108 . I am using a PIC18f452 micro controller