E/X-Mag Microcontroller Programming (Atmel AT90S2313)

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

    #76
    You really are making great progress! Gotta make this post short cause I've gotta run and pick up 2 buddies to head to a scenario game, but yes, you can do what you ask. The AVR allows you to treat the registers as memory (memory mapped). You can use a pointer set to their memory address (see datasheet), move the data from the SRAM location pointed to into a the EEDR, write that to EEPROM, and increment the pointer to SRAM and the EEPROM pointer, and repeat to step through the register block that you want to write.

    Congrats! You've gotten a lot of functionality implemented! You gotta love the world of embedded microcontrollers!

    bit-wizard

    Comment

    • Miscue
      Super Moderator

      • Oct 2000
      • 7105

      #77
      Originally posted by LorneCash
      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

      Cool... good job. Here's somethings you might want to consider. Do not assume that the data read from the EEPROM is correct. It's very possible that you could read in corrupted data, resulting in abnormal behavior.

      The EEPROM stuff is not 100% reliable and varies from chip to chip. Don't use the first EEPROM memory locations to store stuff... go for the middle. This takes care of known EEPROM issues with these Atmels where the front memory locations sometimes get corrupted. Also... there is an issue where your first EEPROM read will corrupt the memory location you are reading. Yes... a read results in a corrupting write! This bug drove me freakin' nuts. It only happens on some chips... at random... difficult to reproduce. To fix it... do a priming read from an EEPROM location that doesn't store anything important. I had like... my stuff stored at EEPROM addresses 20 - 35 or whatever... but I would read from 19 first for the priming read.

      Another thing you might want to do which is in 3.2 and 4.x... write the data 3 times. Make sure that the data you read are within exceptable ranges... like... your ROF should not be read as 255 or something... that's out of range. I also included a checksum as well... 3.x does not have this. This is to help make sure that not only is the data in range, but it is likely to be the same data that was originally stored. If the data is out of range or has a bad checksum... then you try 1 of the other 2 sets of stored data. If all 3 fail, reset the marker to defaults.
      Last edited by Miscue; 12-04-2005, 03:01 PM.

      Comment

      • Miscue
        Super Moderator

        • Oct 2000
        • 7105

        #78
        Hey, post some videos of your software in action!

        Comment

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

          #79
          Originally posted by Miscue
          Hey, post some videos of your software in action!

          I got 20%+ of the chip left to play with and a bit more if i rewrite a few sections like the EEPROM with loops as discused above. I want to see what all i can fit in... I'll probably be done, ready for some beta testing, sometime between Christmas and New Year's. I'll post all the features and hopefully some videos at that point. As for now I have my last set of exams to study for... only 2 but they're both going to be extreemly hard and then finals in 2 weeks so i'm not going to have a lot of time 'till after finals. My last final is the 23th and my first day of rest/first day after college (i'm graduating this semester) is the 24th which just happens to be my birthday, my golden birthday. I'm turning 24 on the 24th and graduating all in one day!! ...Happy me.

          How do I check for the tournament lock? Do i just set one of the 2 pins high and see if the other pin matches? Can I have two jumpers each locking something different, one on the 2 pins above the ACE and the other on the two pins below the ACE, Not that i necessairly would but didn't AGD 1.0 have a full auto jumper on the two pins above the ACE and then later wasn't the Tournament lock applied to the two pins below the ACE?

          Bit-Wizard, can you give me an example of how you to set a pointer to a register? I got an idea but it'd be nice if you could save me the trouble.
          Last edited by LorneCash; 12-04-2005, 08:26 PM.

          Comment

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

            #80
            I put the jumper between PB5 and GND but when I do this it always does the jump jumper or no jumper... How do I do this?


            sbi PORTB,5
            sbic PORTB,5
            rjmp LOCKED

            Stuff to skip if locked

            LOCKED:

            Comment

            • Miscue
              Super Moderator

              • Oct 2000
              • 7105

              #81
              Originally posted by LorneCash
              I put the jumper between PB5 and GND but when I do this it always does the jump jumper or no jumper... How do I do this?


              sbi PORTB,5
              sbic PORTB,5
              rjmp LOCKED

              Stuff to skip if locked

              LOCKED:
              You know... I don't remember exactly what I did. I think I had an issue with it too... messed with the pull-up resistors and got it working. Something counter-intuitive...

              If you can't get it... I'll pull up my code and try to figure out what I did.

              Comment

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

                #82
                Originally posted by Miscue
                You know... I don't remember exactly what I did. I think I had an issue with it too... messed with the pull-up resistors and got it working. Something counter-intuitive...

                If you can't get it... I'll pull up my code and try to figure out what I did.
                Here's my pull up resistor and data direction settings. I tried all 4 combinations with bit 5... No luck. It's not the jumper i checked that too


                ldi Temp_1,0b10111111 ; Set Pullup Resistors(Port B)
                out PORTB,Temp_1 ; Load them

                ldi Temp_1,0b00011100 ; Set Data Direction Register(Port B)
                out DDRB,Temp_1 ; Load it

                Comment

                • bit-wizard
                  Registered User
                  • May 2005
                  • 205

                  #83
                  I think your problem is that you are reading/testing "PORTB", which is the port data register for outputs instead of "PINB", which actually returns the values of the inputs. Your port setup looks correct (bit configured as input, pullup active).

                  bit-wizard

                  Comment

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

                    #84
                    This one falls under the category of I AM AN IDIOT!!! I was flashing an old .hex and didn't realize it... No matter what I did nothing would work... go figure, nothing changed at all... AHhh, This can be frustrating!
                    Last edited by LorneCash; 12-11-2005, 12:02 PM.

                    Comment

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

                      #85
                      Solenoid Wiring Test

                      Here's an easy way to test if your Solenoid is wired correctly... All you'll need is a compas!


                      Step 1
                      Lay your gun on a flat surface. Take a compass and lay it at the bottom of your grip, so that the center of the compas is on the axis of pull for the solenoid.

                      Step 2
                      Orient the whole thing so that the needle of the compass is perpendicular to the axis of solenoid (the needle of the compass points north/south and the solenoid points east/west)

                      Step 3
                      Pull Trigger rapidly (without moving the gun)

                      Solution
                      If the South end of the needle turns and points toward the solenoid while you are pulling the trigger it is correct

                      If the North end of the needle is pointing toward the solenoid it is wired incorrectly and NEEDS to be fixed (Trust me and get it fixed it will solve tons of problems)

                      Comment

                      • Miscue
                        Super Moderator

                        • Oct 2000
                        • 7105

                        #86
                        Originally posted by LorneCash
                        This one falls under the category of I AM AN IDIOT!!! I was flashing an old .hex and didn't realize it... No matter what I did nothing would work... go figure, nothing changed at all... AHhh, This can be frustrating!
                        I've done it before.

                        The bug that drove me nuts... and made me pound my head on the wall... ended up being a problem with the AVR Studio itself... or one of my files got corrupted or something. It would literally skip one of my instructions... and build a bad hex file.

                        I ended up retyping everything into a new .ASM... and everything magically worked. I was kinda torqued about that.

                        Comment

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

                          #87
                          ROF counter

                          I tried doing a ROF counter (AKA MOD2 in 4.xx). I used three different ways to do it. The first used a true one second timer but it seemed slow and i wanted it to update faster than that. Next I tried a 250ms timer which gave me an acceptable resolution but i had to use 4 different registers to store the values and then sum them... This seemed to work alright but for some reason it would cause the software to completely stop functioning after a couple minutes.

                          Any suggestions on how to do a ROF counter?

                          I commented my latest attempt at a ROF counter out temporarely... The rest of the code is ready for official testing.



                          I will be posting a list of features and instructions soon

                          LET THE BETA TESTING BEGIN!!!

                          Comment

                          • Miscue
                            Super Moderator

                            • Oct 2000
                            • 7105

                            #88
                            Originally posted by LorneCash
                            I tried doing a ROF counter (AKA MOD2 in 4.xx). I used three different ways to do it. The first used a true one second timer but it seemed slow and i wanted it to update faster than that. Next I tried a 250ms timer which gave me an acceptable resolution but i had to use 4 different registers to store the values and then sum them... This seemed to work alright but for some reason it would cause the software to completely stop functioning after a couple minutes.

                            Any suggestions on how to do a ROF counter?

                            I commented my latest attempt at a ROF counter out temporarely... The rest of the code is ready for official testing.



                            I will be posting a list of features and instructions soon

                            LET THE BETA TESTING BEGIN!!!
                            1/4-1 second samples will work. I prefer taking it over a whole second... but that's just me.

                            Make vids!

                            Comment

                            • KayleAGD
                              Master tech.
                              • Nov 2000
                              • 582

                              #89
                              Hey lorne , got to keep in mind the one that got you into this mess.. i got AVR and boards ..
                              "It's my buddies gun"
                              "I just bought it"
                              "It came that way"
                              "I borrowed it "
                              I HAVE HEARD THEM ALL, SO BE ORIGINAL !!!

                              My gun says I'm holding it back from doing great things ...

                              Comment

                              • doober
                                Registered User
                                • May 2005
                                • 79

                                #90
                                were do you learn how to program the boards. would java help me becaus ei know java and i was wonderign how close they are thanks

                                Comment

                                Working...