cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
5,013 Views
Registered: ‎06-12-2012

Problem with ch7301c

Can any body help me please:

 

I am trying to run a crt monitor in xc5vlx110t but got stuck with ch7301c . Simulation of this code is working as specified in datasheet and ch7301c is also sending acknowledge bit but code is not working as expected......

 

 

Not able to figure out what is the problem.

 

module main(
input USER_CLK,
output SCL_o,
inout SDA_main,
output reset,
output reg [7:0] led);


wire sda_o;
wire sda_i;
reg bi;
reg [10:0] count_main;
reg [10:0] count;
reg SDA;
reg [10:0] count_bit;
reg [10:0] scl_flag;
reg SCL_R;
reg SCL;
reg [10:0] count_2;


initial
begin
SCL<=1'b1;
count_bit<=11'b00000000000;
SDA<=1'b1;
scl_flag<=11'b00000000000;
SCL_R<=1'b1;
bi<=1;
count_main<=11'b00000000000;
count<=11'b00000000000;
count_2<=11'b00000000000;
led<=8'hff;
end


assign sda_i=SDA_main;
assign SDA_main=(bi)?sda_o:1'bz;
assign sda_o=SDA;
assign SCL_o=SCL;
assign reset=1'b1;



always @(posedge USER_CLK)
begin

    if(scl_flag==0||scl_flag==1)
    begin
            if(count_2==49)
            count<=0;

            else
            count_2<=count_2+1;


            if(count_2==0||count_2==25)
            begin

            if(SCL_R==1'b1)
            begin
                SCL_R<=1'b0;
                scl_flag<=scl_flag+1;
            end
        
            else
            begin
            SCL_R<=1'b1;
            scl_flag<=scl_flag+1;
            end
        
           end
    end
    else if(scl_flag>=2)
    begin
       if(count==99)
        count<=0;

        else
        count<=count+1;
      
        if(count_2==49)
        count_2<=0;

        else
        count_2<=count_2+1;
      

        if(count_2==0||count_2==25)
        begin

            if(SCL_R==1'b1)
            SCL_R<=1'b0;

        
            else
            SCL_R<=1'b1;

        end
        
        if(count==0||count==50)
        begin

            if(SCL==1'b1)
            SCL<=1'b0;
            
            else
            SCL<=1'b1;   
        
        end
   
    
 
end

end





always @(negedge SCL_R)
begin

case(count_bit)
10:SDA<=0;
11:SDA<=1;
13:SDA<=1;
15:SDA<=1;
17:SDA<=0;
19:SDA<=1;
21:SDA<=1;
23:SDA<=0;
25:SDA<=0;
27:;
28:;
29:SDA<=1;
31:SDA<=0;
33:SDA<=1;
35:SDA<=0;
37:SDA<=0;
39:SDA<=0;
41:SDA<=0;
43:SDA<=1;
45:;
46:;
47:SDA<=0;
49:SDA<=0;
51:SDA<=0;
53:SDA<=0;
55:SDA<=1;
57:SDA<=1;
59:SDA<=0;
61:SDA<=1;
63:;
64:;
65:SDA<=0;
66:SDA<=1;

70:SDA<=0;
71:SDA<=1;
73:SDA<=1;
75:SDA<=1;
77:SDA<=0;
79:SDA<=1;
81:SDA<=1;
83:SDA<=0;
85:SDA<=1;
87:;
89:SDA<=1;
91:SDA<=1;
93:SDA<=1;
95:SDA<=1;
97:SDA<=1;
99:SDA<=1;
101:SDA<=1;
103:SDA<=1;
105:bi<=0;
107:;
108:led[7]<=sda_i;
110:led[6]<=sda_i;
112:led[5]<=sda_i;
114:led[4]<=sda_i;
116:led[3]<=sda_i;
118:led[2]<=sda_i;
120:led[1]<=sda_i;
122:led[0]<=sda_i;
123:begin bi<=1; SDA<=0; end
124:SDA<=1;

endcase

if(count_bit<=125)
count_bit=count_bit+1;


end


endmodule


0 Kudos
7 Replies
Highlighted
Visitor
Visitor
5,011 Views
Registered: ‎06-12-2012

Re: Problem with ch7301c

I am first writing to 21 register then again reading from it

 

0 Kudos
Highlighted
Teacher
Teacher
5,006 Views
Registered: ‎09-09-2010

Re: Problem with ch7301c

> but code is not working as expected.

EXACTLY how is it not as expected?
Posting simulation and ChipScope waveforms might help debugging.

 

However, I would advise you to take a course module on FSM design. I am no Verilog expert, but your 'always @(negedge SCL_R)' process is a total abomination!

 


------------------------------------------
"If it don't work in simulation, it won't work on the board."
0 Kudos
Highlighted
Visitor
Visitor
5,002 Views
Registered: ‎06-12-2012

Re: Problem with ch7301c

Device is sending me acknowledge for 21f but not for 33f after writing 21f as 00001101. If i read this register it gives me 00000111;sim.png

 

 

simulation is as specified in datasheet

0 Kudos
Highlighted
Visitor
Visitor
5,001 Views
Registered: ‎06-12-2012

Re: Problem with ch7301c

Plese help me I am stuck with this thing for 10 days

0 Kudos
Highlighted
Instructor
Instructor
4,993 Views
Registered: ‎07-21-2009

Re: Problem with ch7301c

I do not use the Chrontel CH7301C.  Having said that, here are some suggestions:

 

  • If you are using a Xilinx FPGA development board, examine the reference designs for the board for example code and practices.
  • Solicit support from the Chrontel website and/or user forum.
  • Have you downloaded and read the Chrontel register apnote AN-41?

From the New Users Forum README thread:

 

Chrontel CH7301C VGA/DVI video encoder datasheet registers apnote (plus many forum threads discussing this device)

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Highlighted
Visitor
Visitor
4,990 Views
Registered: ‎06-12-2012

Re: Problem with ch7301c

Yes, My protocol exactly as specified in an41

0 Kudos
Highlighted
Historian
Historian
4,986 Views
Registered: ‎02-25-2008

Re: Problem with ch7301c


@khageshpatel wrote:

Can any body help me please:

 

I am trying to run a crt monitor in xc5vlx110t but got stuck with ch7301c . Simulation of this code is working as specified in datasheet and ch7301c is also sending acknowledge bit but code is not working as expected......

 

[snip horrific code]

 


If your simulation DOES NOT include a bus-functional model of the ch7301c, then your simulation is not complete and cannot be said to be "working as specified in datasheet."

----------------------------Yes, I do this for a living.
0 Kudos