cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
merlin_mmii
Visitor
Visitor
1,205 Views
Registered: ‎02-07-2020

Display 7 Segment problem

Jump to solution

Hi.

Before anything I wish that everyone is well with their families.
I have a Spartan-6 XC6SLX9-2FTG256B.

Download a Verilog code to use the 6 digit 7 segment display and configure the UCF file according to the manual.

The program compiles and loads the FPG without any problem, however when pressing the different buttons the LEDs show anything.

I am just thinking about learning to program FPGs, if someone can guide me on what I am doing wrong I would appreciate it

 

The following is the program:

module Decodificador_Binario_7_Segmentos(
input wire [3:0] bin,
output reg [6:0] sseg
);

always @*
case (bin)
4'b1111: sseg[6:0]=7'b1111110;
4'b0001: sseg[6:0]=7'b0110000;
4'b0010: sseg[6:0]=7'b1101011;
4'b0011: sseg[6:0]=7'b1111001;
4'b0100: sseg[6:0]=7'b0110101;
4'b0101: sseg[6:0]=7'b1011101;
4'b0110: sseg[6:0]=7'b1011111;
4'b0111: sseg[6:0]=7'b1110000;
4'b1000: sseg[6:0]=7'b1111111;
4'b1001: sseg[6:0]=7'b1110101;
default: sseg[6:0]=7'b0000000;
endcase
endmodule

 

 

UCF file:

NET "bin(0)" LOC=C3;
NET "bin(1)" LOC=D3;
NET "bin(2)" LOC=E4;
NET "bin(3)" LOC=E3;

NET "sseg(0)" LOC=C7;
NET "sseg(1)" LOC=E6;
NET "sseg(2)" LOC=C5;
NET "sseg(3)" LOC=F7;
NET "sseg(4)" LOC=D6;
NET "sseg(5)" LOC=E7;
NET "sseg(6)" LOC=D5;

 

Image 1: no buttons are pressed, however seal A is lit

20200327_181632.jpg

 

Image 2: key 0 is pressed, which should represent number 1 on the display, however it shows 8.

20200327_181325.jpg

 

Image 3: press key 4, which should represent the number 8 on the display, however it shows the inverted character "C"

20200327_181441.jpg

 

Thanking you for your attention and comments, and wishing a prompt solution to covit-19, you cordially bid farewell.

Rodrigo Letelier.

0 Kudos
1 Solution

Accepted Solutions
dgisselq
Scholar
Scholar
1,180 Views
Registered: ‎05-21-2015

@merlin_mmii,

  1. In your first problem, one light was on when nothing should've been on.  In this case, check that you have the number and pin count correct.  Some 7-segment displays have an 8th element reserved for the decimal place, some allow for controlling the colon in the middle of the display.  Check your FPGA schematic for the actual connections.
  2. Regarding the "C", checking your pinouts might help.  The mapping from 7-bit number to actual 7-segment display isn't always straightforward.  Sometimes it helps to just output a constant, build and test the design, adjust one bit, build and test the design, then note the change.

The key point in these suggestions is that there can be many things at this point that could be wrong.  Your task will be to separate what might or might not be wrong.  For example, some buttons when pressed read '0' others read '1'.  You'll want to make sure you separate the button unknowns from the other unknowns when debugging.

Good luck!

Dan

View solution in original post

2 Replies
dgisselq
Scholar
Scholar
1,181 Views
Registered: ‎05-21-2015

@merlin_mmii,

  1. In your first problem, one light was on when nothing should've been on.  In this case, check that you have the number and pin count correct.  Some 7-segment displays have an 8th element reserved for the decimal place, some allow for controlling the colon in the middle of the display.  Check your FPGA schematic for the actual connections.
  2. Regarding the "C", checking your pinouts might help.  The mapping from 7-bit number to actual 7-segment display isn't always straightforward.  Sometimes it helps to just output a constant, build and test the design, adjust one bit, build and test the design, then note the change.

The key point in these suggestions is that there can be many things at this point that could be wrong.  Your task will be to separate what might or might not be wrong.  For example, some buttons when pressed read '0' others read '1'.  You'll want to make sure you separate the button unknowns from the other unknowns when debugging.

Good luck!

Dan

View solution in original post

u4223374
Advisor
Advisor
1,137 Views
Registered: ‎04-26-2015

After a bit of searching I found the schematics. @dgisselq is exactly right.

From his points:

(1) Yes, there's an eighth pin (C6) which you should probably connect.

(2) The datasheet gives no information about which segment connects where.

 

From the schematic it looks like both switches and LED segments (but NOT the LED digit select lines) are inverted - if you press a switch then you get 0 on that pin, if you release it you get 1. Similarly, if you pull a pin down to 0 then that LED segment turns on, if you set it high then the LED segment turns off.

Consider the display like this:

 AAAA
B    C
B    C
B    C
 DDDD
E    F
E    F
E    F
 GGGH  HH 

Looking at your code, when you don't press any switches (and get 1111 as the input) then you drive one bit (0) low and get one segment activated, so presumably segment A = sseg[0] = C7. When you press switch 1 (and get 1110 as the input) you end up in the default case, outputting 0000000 (so all segments turn on - good). When you press switch 4 (and get 0111 as the input) you turn on the lower four bits of sseg. You already know that sseg[0] = A; presumably sseg[1], sseg[2], and sseg[3] correspond to C, D, and F (although possibly not in that order).

 

As @dgisselq said, you'll need to do some experimenting:

(1) Start by sticking an inverter on the inputs and outputs to your block (that way you can use "sensible" logic within the block, where 1 means on and 0 means off).

(2) Add a bit to sseg so you can drive all eight outputs.

(3) Set the four switches to drive sseg[3:0] directly. Pressing each switch tells you which bit of sseg is connected to which LED segment.

(4) Repeat the above with the switches driving sseg[7:4].

(5) Adjust the order of bits in your code to get the appropriate digits.