Atmel Studio 7. 7 Segment Display Code Help

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone, I'm working on a school project requiring me to code a 7 segment LED display to show my student number. We are required to create a Clock with a time wasting delay which I have done. I'm now stuck in a position where I have no clue where to go. My teacher refuses to assist me as we are supposed to outsource our knowledge for the project. I have seen some post on here about 7 segment displays but have not found anything similar to my situation. I am using AS7 with assembler not C++/C

 

Some assistance would be greatly appreciated.

 

Thanks.

 

Here is my code:

 

.org $0
rjmp start

.org $60

.def clock = r16

start: 
        // Point SP to RAMEND
        ldi r16, low(RAMEND)
        out SPL, R16
        ldi r16, high(RAMEND)
        out SPH, r16

        // Set all of PORT A to Outputs
        ldi R16, $FF
        out DDRA, R16
         
ClockHigh:
        // Clock High
        ldi clock, $01
        out PORTB, clock
        call delay

ClockLow:
        // Clock Low
        ldi clock, $00
        out PORTB, clock
        call delay
        rjmp ClockHigh

        
delay:
        ldi r20, $20

loop:
        ldi r18, $FF

outerloop:
        ldi r19, $FF

innerloop:
        dec r19
        brne innerloop
        dec r18
        brne outerloop
        dec r20
        brne loop
        ret

Jordy C

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You’ve not told us much. Step by step, what do you want to do?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So essentially we were given a project brief to design, construct and test  a digital circuit that will display my student number on a seven-segment display. A four bit modulo-11 counter from a hardware counter or a microcontroller is to provide the data via a two channel multiplexer to a decoder. 

 

The first step I was given to complete was to create a clock and delay which i have done in the above code. We were tasked to create an ATMEGA32 board to use in combination with an ATF2500C chip. 

 

I have attached the block diagram so that you can see the layout. 

My next step I assume is not create a database in AS7 containing all the bytes of my student number.

For some reason the task requires the numbers to be printed in a certain order

 

My number is 3720061, this will then be followed by three dashes (7 segment alphabet in attachments) then my initials J C then another set of dashes.
For my particular order it is changed to:

 

61(dash)JC(dash)37200 

 

6 = 0100000

1 = 1001111

(dash) = 0110110

J = 1000111

C = 0110000

(dash) = 0110110

3 = 0000110

7 = 0001111

2 = 0010010

0 = 0000001

0 = 0000001

 

I need to know how to enter these into my code and be able to display them in that order to the 7 segment LED display

If you require anymore Info please let me know

 

Attachment(s): 

Jordy C

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All you need is the AVR  & perhaps some driver transistors ...why on earth do you need a CPLD?  Are you trying to learn those too? 

The AVR has more than enough horsepower to decode & run some 7-seg displays. 

 

if "clock" is r16...you should not use "r16" anywhere in your program ...use "clock" ...you gave it that name

Name the others too, as needed.  Don't use rxx, too many mistakes...note ZH, ZL, XH, XL, YH, YL are built in deafaults for you to use.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Your first job is to sit down with pencil, paper and a nice cup of tea.

 

Design your program.

 

You can write down some ideas.

You can draw some flowcharts.

You can hand-trace the the program flow by drawing pencilled arrows as you follow the flowchart.

 

When you are happy with the basic design,  you can expand the individual blocks.  e.g. to the programming language level

 

It is at this stage that you ask technical questions.   e.g. how to implement a specific block in ASM

 

If you have shown that you have done your design work,   we will be happy to help with ASM statements,  loops etc.

You don't need fancy CAD artwork.   A photo of neat pencil flowchart with clearly written labels and comments.

 

Hint.   Your assignment might be for ASM but there is nothing to stop you doing it in C.    Then inspect the Compiler generated ASM.

You might even pick up some design ideas from an existing C program.

 

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You 7 segment alphabet has more than 16 entries - how are going to control this via 4 bits?

 

As for a 'database' - one solution is just to write code that implements your sequence. If you want to be a little smarter you can create a table then write code to step through this and display then delay,next and so on. According to your hardware diagram, I have no idea how you are going to implement your 7 segment alphabet - the 'usual' solution would be to connect the 7 segments and decimal point to 8 port pins. Doing this, the solution is trivial.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jordy C wrote:
My teacher refuses to assist me as we are supposed to outsource our knowledge for the project

I'm reminded of the phrase: "Those that can - do. Those that can't - teach". Your teacher refuses to assist because he's ignorant. All you need is a nudge in the right direction. A good teacher would be able to help you get back on the right track by asking questions of you and what you noticed without spoon-feeding you a solution.

 

Jordy C wrote:
The first step I was given to complete was to create a clock and delay which i have done in the above code. We were tasked to create an ATMEGA32 board to use in combination with an ATF2500C chip. 

  • Step-1: In this first step you were simply clocking the modulo-11 counter (Channel-A) within the PLD. What did you see on the 7-Seg? I'll guess ('Blank', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
  • Step-2: An interesting experiment would be to knock up some code to use Channel-B and cycle through all 16 values there and note what appears on the 7-Seg.

 

Hey Hey Hey - You never know! Your Teacher may have programmed your PLD to include ... (I'll stop now so as not to spoon feed you).

 

 

Last Edited: Sat. Oct 12, 2019 - 10:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to those who have replied, unfortunately, I have very limited knowledge about AS7 and how to do this project.

We were tasked to use it to get extra marks but were not taught how to do it, just the very basics

 

The first portion of the project was to code in WinCUPL which I completed with ease. 

I am lost as to how to code this in AS7 though.

 

I know that I have to store my student number so that when I connect my microcontroller to the 7seg it will display my number in the correct order

I know there must be a clock and a 1 sec delay

There must also be a select line (S-Line) which determines where the inputs come from.

 

Would it be helpful for me to link my WinCUPL code?

I know it may seem like spoonfeeding but we have been given no resources for this stuff. 

If you look at the layout.png I linked, the aspect we are using AS7 for is when the select line = 1 and the B channel is being used from the microcontroller. The 4 bit binary counter is not included in this portion of the assignment if that makes sense.

 

 

 

Jordy C

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I gather these are the 7 segment encoded values:

 

 

6 = 0100000

1 = 1001111

(dash) = 0110110

J = 1000111

C = 0110000

(dash) = 0110110

3 = 0000110

7 = 0001111

2 = 0010010

0 = 0000001

0 = 0000001

 

If this is the case, the code is pretty much like the code you posted - output value, delay, output next value, delay and so on.

 

Again, how do we get control of the 7 segments via 4 bits?

Last Edited: Sun. Oct 13, 2019 - 01:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jordy C wrote:
The first portion of the project was to code in WinCUPL which I completed with ease.

WTF:

I didn't know what WinCUPL was so looked it up

WinCUPL

A complete, easy-to-use, Windows based design software for all Microchip SPLDs and CPLDs.  It supports CUPL design entry, functional simulation, and includes the latest Fitter technologies.

Again WTF:

Are you learning AVR Microcontroller or Programmable Logic Devices ?

I'll guess Programmable Logic Devices because the reverse makes absolutely no sense at all.

 

I notice that your character sequence "61-JC-32700" is exactly 11 characters. So given that:

 

  1. You know how to program Atmel/Microchip CPLDs
  2. You can clock the modulo-11 counter using your AVR

 

You're now in a position to write/program some simple combinatorial logic to generate the 7-Seg and successfully complete your assignment.