Page 3 of 25 FirstFirst 123456713 ... LastLast
Results 61 to 90 of 736

Thread: E/X-Mag Microcontroller Programming (Atmel AT90S2313)

  1. #61
    Join Date
    May 2005
    Location
    Virginia
    Posts
    205
    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

  2. #62
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    Quote 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?

  3. #63
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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?

  4. #64
    Join Date
    May 2005
    Location
    Virginia
    Posts
    205
    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
    .




    Quote 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?

  5. #65
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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 at 09:34 PM.

  6. #66
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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.

  7. #67
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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 at 03:07 AM.

  8. #68
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    Quote 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)

  9. #69
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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.

  10. #70
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    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 at 07:45 PM.

  11. #71
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    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.

  12. #72
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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?

  13. #73
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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 at 06:05 PM.

  14. #74
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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.

  15. #75
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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

  16. #76
    Join Date
    May 2005
    Location
    Virginia
    Posts
    205
    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

  17. #77
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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 at 04:01 PM.

  18. #78
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Hey, post some videos of your software in action!

  19. #79
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    Quote 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 at 09:26 PM.

  20. #80
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    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:

  21. #81
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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.

  22. #82
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    Quote 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

  23. #83
    Join Date
    May 2005
    Location
    Virginia
    Posts
    205
    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

  24. #84
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365
    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 at 01:02 PM.

  25. #85
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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)

  26. #86
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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.

  27. #87
    Join Date
    Aug 2005
    Location
    Milwaukee WI
    Posts
    365

    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!!!

  28. #88
    Join Date
    Oct 2000
    Location
    Las Vegas, NV
    Posts
    7,105
    Quote 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!

  29. #89
    Join Date
    Nov 2000
    Location
    Henderson, Ky
    Posts
    582
    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 ...


  30. #90
    Join Date
    May 2005
    Location
    houston, texas
    Posts
    79
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •