E/X-Mag Microcontroller Programming (Atmel AT90S2313)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bit-wizard
    Registered User
    • May 2005
    • 205

    #61
    You can use the .org directive to specify an actual address to locate the data at. Also, you may want a separate label for each character. Something like ...

    CHARMAP:
    ZERO:
    .DB (DATA)
    ONE:
    .DB (DATA)
    TWO:
    .DB (DATA)

    and so on.


    Then, to access the character data, load the symbol that specifies the character data that you want into your pointer register, and access it via the pointer with the LPM command. Read up on LPM ... the address you want must be modified slightly to work with it. I think it requires a shift, but I don't remember which direction.

    bit-wizard

    Comment

    • LorneCash
      Got XMOD? www.NiedTech.com
      • Aug 2005
      • 365

      #62
      Originally posted by bit-wizard
      You can use the .org directive to specify an actual address to locate the data at. Also, you may want a separate label for each character. Something like ...

      CHARMAP:
      ZERO:
      .DB (DATA)
      ONE:
      .DB (DATA)
      TWO:
      .DB (DATA)

      and so on.


      Then, to access the character data, load the symbol that specifies the character data that you want into your pointer register, and access it via the pointer with the LPM command. Read up on LPM ... the address you want must be modified slightly to work with it. I think it requires a shift, but I don't remember which direction.

      bit-wizard

      Let's say I use the .ORG to tell it where to go like you said, like this:

      .ORG 0x03FF (or whatever the memory address would be)
      CHARMAP:
      ZERO:
      .DB (DATA)
      ONE:
      .DB (DATA)
      TWO:
      .DB (DATA)

      how do I tell it when i'm done defining that specific section to just go back to writing contiguously so i don't waste memory space?

      Comment

      • Miscue
        Super Moderator

        • Oct 2000
        • 7105

        #63
        Originally posted by LorneCash
        Let's say I use the .ORG to tell it where to go like you said, like this:

        how do I tell it when i'm done defining that specific section to just go back to writing contiguously so i don't waste memory space?
        Not sure what you mean... can you clarify?

        What is represented by charmap anyway? These the bitmaps for your characters that are drawn to the LED?

        Comment

        • bit-wizard
          Registered User
          • May 2005
          • 205

          #64
          You can just use another .org directive. For instance, you could place it at the end of your vector table, then follow it with a labeL that you place in your reset vector location that will get jumped to on reset.

          .org 0x00
          jmp Start
          [Rest of Vectors here]

          CHARMAP:
          .....

          Start:
          [Code here]


          bit-wizard
          .




          Originally posted by LorneCash
          Let's say I use the .ORG to tell it where to go like you said, like this:

          .ORG 0x03FF (or whatever the memory address would be)
          CHARMAP:
          ZERO:
          .DB (DATA)
          ONE:
          .DB (DATA)
          TWO:
          .DB (DATA)

          how do I tell it when i'm done defining that specific section to just go back to writing contiguously so i don't waste memory space?

          Comment

          • LorneCash
            Got XMOD? www.NiedTech.com
            • Aug 2005
            • 365

            #65
            My Display Code (I know its ugly)

            OK here's what I've got, this is an included file. I display the stuff with these 4 lines
            EDIT - Code Removed
            I had posted about 3 pages of ugly code here... It was all wrong and i don't want anyone to copy it thinking that it would help them so I removed it. Trust me it's in your best interest.
            Last edited by LorneCash; 12-04-2005, 08:34 PM.

            Comment

            • LorneCash
              Got XMOD? www.NiedTech.com
              • Aug 2005
              • 365

              #66
              Moving Location of CHARMAP

              For some reason it doesn't give me the same results when i put the CHARMAP at the top where you see it commented.

              Compiled like this it does work but i need someone to help me with geting a pointer with an offset in there otherwise i just wind up overwriting my stack and everything goes goophy.

              Comment

              • Miscue
                Super Moderator

                • Oct 2000
                • 7105

                #67
                Originally posted by LorneCash
                For some reason it doesn't give me the same results when i put the CHARMAP at the top where you see it commented.

                Compiled like this it does work but i need someone to help me with geting a pointer with an offset in there otherwise i just wind up overwriting my stack and everything goes goophy.
                What do you mean by overwriting the stack? Didn't you initialize the stack pointer somewhere?

                I'm looking at what you have... and it seems odd. This is what mine looks like:

                BOOT_STRING: .DB "BECAUSE QUALITY ALWAYS SHOOTS STRAIGHT AGD 4.20", 0x00

                ACE_MENU: .DB "ACE", 0x00
                ROF_MENU: .DB "ROF", 0x00

                .
                . etc... etc...
                .

                You don't need to define constants for individual letters and numbers... just type them outright. Take advantage of the fact that these characters correspond to ASCII values... in order... and use an offset scheme to route the character to the correct offset for the charmap.

                Oh, I noticed this as well in your code:

                "sbi PORTB,DS1_CLK
                cbi PORTB,DS1_CLK"

                It's used multiple times... so use a function call instead:

                rcall pulseClock

                pulseClock:
                sbi PORTB, DS1_CLK
                cbi PORTB, DS1_CLK
                ret

                Lookin' good! You're getting there!

                How much programming space do you have left?
                Last edited by Miscue; 12-01-2005, 02:07 AM.

                Comment

                • LorneCash
                  Got XMOD? www.NiedTech.com
                  • Aug 2005
                  • 365

                  #68
                  Originally posted by Miscue
                  What do you mean by overwriting the stack? Didn't you initialize the stack pointer somewhere?

                  I'm looking at what you have... and it seems odd. This is what mine looks like:

                  BOOT_STRING: .DB "BECAUSE QUALITY ALWAYS SHOOTS STRAIGHT AGD 4.20", 0x00

                  ACE_MENU: .DB "ACE", 0x00
                  ROF_MENU: .DB "ROF", 0x00

                  .
                  . etc... etc...
                  .

                  You don't need to define constants for individual letters and numbers... just type them outright. Take advantage of the fact that these characters correspond to ASCII values... in order... and use an offset scheme to route the character to the correct offset for the charmap.


                  How much programming space do you have left?


                  Yea i do initialize the stack pointer. I think the problem is with defining all the characters individually. I know I don't need to do that but i'm not sure how this display code works. I got this section from another guy who got them from someone else and I really don't understand it. The display is the only part of my software that I did'n write myself. I've tried to write it myself but every time i do it doesn't work and i'm not sure why.

                  can you explain what needs to be done in pseudocode or a flowchart or something? Really the main problem is I don't understand it. Should i just trash this and start over or is this code fixable? I know you said before that you can write messages in quotes but i have no idea how to add the pointer and offset into the code i have, again because i don't understand what i do have. Is there any additional documentation on Agilent display other than what's on their website?

                  I really have everything done except the Display, the BPS counter and reading/writing to the EEPROM. All the menus work there's just no text. I have a word document that i have to look at to remember where in the menus i am...lol

                  I've only used 50% of the memory so far. (including the character map and the display stuff above)

                  Comment

                  • Miscue
                    Super Moderator

                    • Oct 2000
                    • 7105

                    #69
                    Originally posted by LorneCash
                    Yea i do initialize the stack pointer. I think the problem is with defining all the characters individually. I know I don't need to do that but i'm not sure how this display code works. I got this section from another guy who got them from someone else and I really don't understand it. The display is the only part of my software that I did'n write myself. I've tried to write it myself but every time i do it doesn't work and i'm not sure why.

                    can you explain what needs to be done in pseudocode or a flowchart or something? Really the main problem is I don't understand it. Should i just trash this and start over or is this code fixable? I know you said before that you can write messages in quotes but i have no idea how to add the pointer and offset into the code i have, again because i don't understand what i do have. Is there any additional documentation on Agilent display other than what's on their website?

                    I really have everything done except the Display, the BPS counter and reading/writing to the EEPROM. All the menus work there's just no text. I have a word document that i have to look at to remember where in the menus i am...lol

                    I've only used 50% of the memory so far. (including the character map and the display stuff above)
                    I dunno if I'll have time to do this... maybe on a weekend.

                    What documentation are you using for the Agilent?

                    I would personally rewrite what you have. I'm not sure who wrote it originally... but it's pretty bad.

                    Comment

                    • Miscue
                      Super Moderator

                      • Oct 2000
                      • 7105

                      #70
                      Once you can draw a dot, or a blank to the LED... it's simple to draw a character and then a string. Besides initializing the LED screen... this is all that is important:



                      ; ************************** Pixel SUBROUTINES ****************************
                      ; *
                      ; * Input line to LED is set high or low. Clock pulse latches data.
                      ; *

                      drawDot:
                      sbi PORTB, 3
                      rcall clock
                      ret

                      drawBlank:
                      cbi PORTB, 3
                      rcall clock
                      ret

                      clock:
                      sbi PORTB, 2
                      cbi PORTB, 2
                      ret

                      ; *
                      ; *
                      ; *
                      ; ******************************** End Pixel *******************************


                      So let's say you have this (letter A) saved in your character map:

                      --XXX--
                      -X---X-
                      -X---X-
                      -XXXX-
                      -X---X-
                      -X---X-
                      -X---X-

                      The LED feeds serially... top to bottom, right to left. You read from the charmap... light a pixel if it's marked, and feed a blank pixel when it's not supposed to be lit up. Also remember that there is an invisible 8th row.

                      All it is... is a couple repeat loops.
                      Last edited by Miscue; 12-01-2005, 06:45 PM.

                      Comment

                      • LorneCash
                        Got XMOD? www.NiedTech.com
                        • Aug 2005
                        • 365

                        #71
                        I'm getting closer, my logic must be off a bit... I rewrote my display routine so that i understand it and now I'm getting consistently wrong output. The key word there is consistent! Time for me to Sleep ZZZZzzz... I'll have to go over the logic tomorrow.

                        Comment

                        • LorneCash
                          Got XMOD? www.NiedTech.com
                          • Aug 2005
                          • 365

                          #72
                          Incramenting ROF?

                          OK I have the display working kinda, I got the string to display as long as none of the characters are greater than ASCII I... I'll work on that i'm pretty sure i can figure that out.

                          Here's where I'm a bit confused... How do you incrament a number on the displays right 4 characters without clearing the left 4 characters, or do you have to write all 8 every time?
                          Do i literly have to write out:

                          ROF_8: .DB "ROF 8",0xFF
                          ROF_9: .DB "ROF 9",0xFF
                          ROF_10: .DB "ROF 10",0xFF


                          Is there a way to disable the left hand side so that latch will only latch the right 4 characters? May be that's the wrong path all together... How should i proceed?

                          Comment

                          • Miscue
                            Super Moderator

                            • Oct 2000
                            • 7105

                            #73
                            Originally posted by LorneCash
                            OK I have the display working kinda, I got the string to display as long as none of the characters are greater than ASCII I... I'll work on that i'm pretty sure i can figure that out.

                            Here's where I'm a bit confused... How do you incrament a number on the displays right 4 characters without clearing the left 4 characters, or do you have to write all 8 every time?
                            Do i literly have to write out:

                            ROF_8: .DB "ROF 8",0xFF
                            ROF_9: .DB "ROF 9",0xFF
                            ROF_10: .DB "ROF 10",0xFF


                            Is there a way to disable the left hand side so that latch will only latch the right 4 characters? May be that's the wrong path all together... How should i proceed?
                            You have to rewrite the whole thing. Set the LED Matrix to sleep while you're doing this... so that this process happens invisibly. Otherwise it looks funny because you can see the LED flicker while it's feeding data into it.

                            There is no reason to have a separate string for each ordinal value. You'll end up with dozens of unnecessary string declarations if you do that. Instead, output "ROF" as a string... and then make a separate subroutine that converts a decimal number to a character... which gets drawn to the LED.
                            Last edited by Miscue; 12-02-2005, 05:05 PM.

                            Comment

                            • LorneCash
                              Got XMOD? www.NiedTech.com
                              • Aug 2005
                              • 365

                              #74
                              Eeprom

                              Display works great, I finished my menus today! I guess a few small tips was all i needed. Thanks Miscue and Bit-Wizard, you guys rock!

                              Now on to the EEPROM, this actually looks fairly simple.

                              Comment

                              • LorneCash
                                Got XMOD? www.NiedTech.com
                                • Aug 2005
                                • 365

                                #75
                                BPS Counter

                                EEPROM's done that was easy, now on to the BPS counter... Now this actually feels like progress.

                                The EEPROM works, but in the intersest of making the code smller, is there a way to make a loop that will write a block of contiguous registers to the EEPROM like this? What i really want to know is if there is a way to incrament the register by using a pointer of memory address or something... The line in bold is the only one that has a problem

                                WRITE:
                                sbic EECR,EEWE ; if EEWE not clear
                                rjmp WRITE ; wait
                                ldi YL,10 ; Load first memory location to write to
                                WRITE_LOOP:
                                out EEAR,YL ; Set output address
                                out EEDR,$00+YL ; Set Data to Write
                                sbi EECR,EEMWE ; set master write enable, remove if 1200 is used
                                sbi EECR,EEWE ; set EEPROM Write strobe
                                inc YL ; incrament loop counter
                                cpi YL,18 ; test exit loop condition
                                brne WRITE_LOOP ; loop if not equal
                                ret

                                Comment

                                Working...