Search code examples
verilogfpgaxilinxled

Led panel doesn't work with constant address and color values


I try to make my led panel (20x40 leds with 1/5 scan mode) work on Spartan-6. I wrote simple code, where I assign SCLK to internal clock signal clk 1MHz, LCLK to ~clk, address ABC and color RGB pins to some constant values.

    module main(
    output reg A,B,C,R1,G1,B1,R2,G2,B2,CS,
    output wire S,L,OE,
    input clk
        );

    initial
    begin
        CS<=1;
        {A,B,C}<=3'b001;
        {R1,G1,B1}<=3'b001;
        {R2,G2
    end

    assign OE=0;

    assign S=clk;
    assign L=~clk;

    endmodule

And I got black panel. But if I load this code

    module main(
    output reg A,B,C,R1,G1,B1,R2,G2,B2,CS,
    output wire S,L,OE,
    input clk
        );

    reg [3:0] state;

    initial
    begin
        state<=0;
        CS<=1;
    end

    assign OE=0;

    always @(posedge clk)
    begin
        case (state)
        00: begin
            {A,B,C}<=3'b000;
            {R1,G1,B1}<=3'b001;
            {R2,G2,B2}<=3'b010;
            state<=state+1;
            end
        01: begin
            {A,B,C}<=3'b001;
            {R1,G1,B1}<=3'b101;
            {R2,G2,B2}<=3'b110;
            state<=state=1;
            end
        02: begin
            {A,B,C}<=3'b010;
            {R1,G1,B1}<=3'b100;
            {R2,G2,B2}<=3'b011;
            state<=state+1;
            end 
        03: begin
            {A,B,C}<=3'b100;
            {R1,G1,B1}<=3'b011;
            {R2,G2,B2}<=3'b010;
            state<=state+1;
            end 
        04: begin
            {A,B,C}<=3'b101;
            {R1,G1,B1}<=3'b111;
            {R2,G2,B2}<=3'b010;
            state<=0;
            end 
        endcase
    end

    assign S=clk;
    assign L=~clk;

    endmodule

Although this code works, the colors are the same in all 5 led columns and correspond to the values in state 0.

I don't understand why it is happening, please help.

Additionally, I can't guess address for one line. Rows on 000,001,010,100 addresses lit, but the rest addresses don't work. (I am changing them in state 04). I have only 3 address pins.


Solution

  • The main problem was the panel has embedded timer that turn off whole panel if I don't change address combination in 50 ms. This is why panel doesn't work with constant address values. Second problem was I didn't understand correctly data&address synchronization. This is why I have problem with columns. And finally, I just didn't try all address combination, although I thought I did it :) Hope my experience can help somebody.