Shop OBEX P1 Docs P2 Docs Learn Events
I must be missing something obvious but can't figure it out. - $50 reward offer — Parallax Forums

I must be missing something obvious but can't figure it out. - $50 reward offer

Jack BuffingtonJack Buffington Posts: 115
edited 2010-04-26 00:24 in Propeller 1
I have really tried to figure this one out but after hours of trying to attack this problem from several angles, I'm at a loss. I'm working on code that grabs pixels from a VGA 640x480x60Hz source. The propeller can only just barely keep up with the signal so I'm reading data from a lookup table for each scan line to tell it what to do. Here is my setup: At each horizontal sync, I read several longs from hub RAM. I have variables to tell it how to capture up to three groups of pixels. Each of the first three longs that I read corresponds to one group of pixels. Specifically, it contains 10 bits telling it how long to wait after the end of the Hsync pulse or the beginning of the previous capture, how many groups of eight pixels to capture (4 bits), and finally, where to write the pixels into hub RAM.

Below is a chunk of code that does some of my scan line routine. For some reason group1numBlocks is getting corrupted but I just can't see how. I have verified that it is seeing the proper numbers of blocks to capture at the proper times using the commented out code below but for some reason the code always just captures one block on scan lines that it is supposed to capture something UNLESS I explicitly tell the program in code like I have in the last line in my sample code. Any ideas? I have been struggling for many hours on this one...

             ' ############################################
             ' read four longs from hub RAM and put
             ' their data into the appropriate variables
             ' ############################################
              rdlong    group1wait,hubLookupLocation
              mov       group1hubLoc,group1wait
              add       hubLookupLocation,#4
              
              rdlong    group2wait,hubLookupLocation
              mov       group2numBlocks,group2wait 
              add       hubLookupLocation,#4
              
              rdlong    group3wait,hubLookupLocation
              mov       group3numBlocks,group3wait
              add       hubLookupLocation,#4
              
              rdlong    OKtoSend,hubLookupLocation
              add       hubLookupLocation,#4                                  



{
 Capture Data
 | 2 bits |    10 bits   | 4 bits |     16 bits      |
 |not used|cycles to wait| number | offset from start|  
 |        | from end of  |   of   | of pixel data to |
 |        | Hsync pulse  | blocks | write this data  |
}
              '###################################
              ' Separate the variables for group1                            
              '###################################
              shr       group1wait,#16
              mov       group1numBlocks,group1wait
              shr       group1wait,#4
              and       group1numBlocks,numBlocksMask   wz
              and       group1hubLoc,hubLocMask
              add       group1hubLoc,pixelDataStartAddress

              ' If at this point I can do a compare to see if number of
              ' blocks is 1,2, or 7 (because those are the values I'm using)
              ' it correctly detects it and lights the LED at the appropriate
              ' times

             { cmp       group1numBlocks,#2      wz
        if_z  or        outa,LEDmask
        if_nz andn      outa,LEDmask
              cmp       group1numBlocks,#0      wz     }
               
              

              ' The very next statement makes use of group1numBlocks but it appears that it
              ' somehow is forgetting the real value and always uses a value of one. On the other
              ' hand, if I insert the following statement, it always will use seven as the value.
              ' What the heck!!!

              'mov       group1numBlocks,#7




Here is a sample of the lookup table data for one scan line:
long   $17C705B0, $F4400030, $30, $2C000000



The long that I am specifically dealing with is the first one.
17C is how long to wait before capturing the pixels after the horizontal sync
7 is how many groups of eight pixels I want to capture
05B0 represents the offset from the start of the pixel data to save these pixels.

Post Edited (Jack Buffington) : 4/25/2010 3:35:50 AM GMT

Comments

  • bill190bill190 Posts: 769
    edited 2010-04-25 00:06
    Should the 2nd line of the 1st entry say...
    ·············mov·······group1numBlocks,group1wait

    ··············rdlong····group1wait,hubLookupLocation
    ··············mov·······group1hubLoc,group1wait
    ··············add·······hubLookupLocation,#4

    ··············rdlong····group2wait,hubLookupLocation
    ··············mov·······group2numBlocks,group2wait
    ··············add·······hubLookupLocation,#4
  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-04-25 03:24
    No. That is just an artifact of having some code for the other two captures but not actually doing them yet so I only bothered to change the code for the first capture intending to change theo others later when I get the first one working perfectly.

    It just doesn't make sense to me that I can light up an LED when the variable is correct but the program won't use that data properly. If on the other hand I explicitly tell it what the variable value is in code and ignore the lookup table variable, it works.

    Here is some more code showing what happens afterwards for what it is worth. Pretty much to maximize the speed of execution, I have code for capturing pixels that simply takes ina and copies it to a variable. Each line of code copies to the next variable location. An example would be

                  mov       pixelData+4,ina
                  mov       pixelData+5,ina
                  mov       pixelData+6,ina
                  mov       pixelData+7,ina
    
    



    I am doing a similar thing with storing the pixels: (i'm dealing with 16-bit color)
                  wrword    pixelData+4,hubPixelLocation
                  add       hubPixelLocation,#2
                  wrword    pixelData+5,hubPixelLocation
                  add       hubPixelLocation,#2
                  wrword    pixelData+6,hubPixelLocation
                  add       hubPixelLocation,#2
    
    



    My code figures out how many pixels should be captured and then puts a jump to the store routine after the last pixel is captured. The store routine stores the captured pixels in hub RAM and then jumps to a restore routine that restores a backup of the jump point out of the capture code and restores the store routine jump point as well.

                  mov       grab2,group1numBlocks
                  mov       store2,group1numBlocks
                  
                  shl       grab2,#3                ' each grab block is 8 instructions
                  add       grab2,#grab1
    
                  
                  shl       store2,#4                'each store block is 16 instructions
                  add       store2, #store1
    
                  
            
            
                  '##############################################
                  ' Backup the instruction at grab2 then replace
                  ' it with a jump to the store routine.
                  ' Also modify the store routine to jump out 
                  ' when it has finished with group1's pixels. 
                  '##############################################
                  movs      modify01,grab2
                  movd      modify02,grab2
                  movd      modify03,store2
                    
    modify01      mov       grab2backup,#0-0
    modify02      mov       0-0, jumpToStoreInstruction    
    modify03      mov       0-0,jumpToRestoreInstruction      
    
                  
                  '#############################
                  ' This is the capture routine 
                  '#############################
    capture01     
                  add       group1wait,HsyncTime
                  waitcnt   group1wait,#0
                  jmp       #grab1 
    
    



    I could really use help on this one. I'll order $50 in Parallax products (your choice) to the first person who can point out what the heck I'm doing wrong.

    Post Edited (Jack Buffington) : 4/25/2010 3:34:38 AM GMT
  • NefariousNefarious Posts: 2
    edited 2010-04-25 05:11
    Start with a clear table/array
  • mparkmpark Posts: 1,305
    edited 2010-04-25 05:45
    If I understand you correctly, your commented-out test code lights an LED indicating that group1numBlocks = 2, even though you expect it to be 7??

    You say "The very next statement makes use of group1numBlocks"—what is the very next statement?

    You really should post the whole program after you've trimmed it down as much as possible.
  • Mike HuseltonMike Huselton Posts: 746
    edited 2010-04-25 10:55
    Post Edited (Jack Buffington) : 4/25/2010 3:34:38 AM GMT
    Is the last response!!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH

  • BaggersBaggers Posts: 3,019
    edited 2010-04-25 11:13
    I'm assuming numBlocksMask is

    numBlocksMask long 15

    as you have 4 bits set aside for it, in the capture data, but you're doing shr group1wait,#16 to shift the bits into place.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • kuronekokuroneko Posts: 3,623
    edited 2010-04-25 12:22
    Jack Buffington said...

                  '##############################################
                  ' Backup the instruction at grab2 then replace
                  ' it with a jump to the store routine.
                  ' Also modify the store routine to jump out 
                  ' when it has finished with group1's pixels. 
                  '##############################################
                  movs      modify01,grab2
                  movd      modify02,grab2
                  movd      modify03,store2
                    
    modify01      mov       grab2backup,#0-0              ' grab2backup := %00000000_00000000_0000000x_xxxxxxxx
    modify02      mov       0-0, jumpToStoreInstruction    
    modify03      mov       0-0,jumpToRestoreInstruction      
    
    
    

    This code does not backup the instruction at grab2, it merely moves the value of grab2 (the register index, e.g. 42) into grab2backup. So if you want the instruction at 42 get rid of the #. Having said that, we really could do with some more code.

    Post Edited (kuroneko) : 4/25/2010 1:10:06 PM GMT
  • NefariousNefarious Posts: 2
    edited 2010-04-26 00:17
    Yes I am a first time poster...
  • Jack BuffingtonJack Buffington Posts: 115
    edited 2010-04-26 00:24
    Kuroneko gets the prize. It is working now. What should I buy you and where should I send it? If you aren't cool with posting your address online, you can e-mail me at temp2010.j.b@buffingtonfx.com

    Thanks!!!
Sign In or Register to comment.