Shop OBEX P1 Docs P2 Docs Learn Events
I need help with asm code pls — Parallax Forums

I need help with asm code pls

Rick_HRick_H Posts: 116
edited 2010-09-30 05:56 in Propeller 1
I am trying to write a generic asm I2C script for my project and am having a problem with isolating a bit in an integer. <-- I think that's the problem.

hear is my code for the buss
con
  
  _clkmode      = xtal1 + pll16x
  _xinfreq      = 5_000_000
VAR
  long flag, amp[8], clock
  long cog

PUB start : okay 
 
okay := cog := cognew(@entry, @flag) + 1

DAT
                          org                                   ' Sets the origin at zero for this point
entry                     or      DIRA,     i2cSDA             ' Sets relevant pin to an output
                          
                          xor     DIRA,     i2cSDL             ' Sets relevant pin to an output
                          
                          mov     time,     CNT                 ' Current clock loaded into time
                          add     time,     off_time            '
                               
loop                      mov     OutHolder,address              'move data to placeholder
                          shl     OutHolder,idxL                 'shift indexed bit to msb clears all higher bits
                          shr     OutHolder,shiftR               'shift bit to lsb clears all lower bits
                          
clkloop                   waitcnt time,     off_time             ' clock time
              
                          xor     OUTA,     i2cSDA               'toggle clock
                          xor     CkState,  #1                   'set clock pin state indicator       
                          waitcnt time,     off_time             'wait 1/2 clock pulse
                          cmp     CkState,  #1      wz, wc       'check for low clock pulse and alow data pin change on low
            if_z          jmp     #clkloop                       'if not = 0 then finish clock pulse
            
                          
                          cmp     OutHolder,DtState              'check data pin state to data bit
                     
            
            if_z          sub     idx,      #1                   'if the same incrament idx
                          add     idxL,     #1                   'incrament shift index for bit placement
            if_z          jmp     #loop                          'if data the same state as pin go to clock
             
pinSDL                    xor     OUTA,     i2cSDL               ' toggle data pin
                          xor     DtState,  #1                   ' toggle data state var
                          djnz    idx,      #loop                ' repeate for each bit in a byte
                          mov     idx,      #8                   '
                          mov     idxL,     #23
                          jmp     #loop



Out1        long          
Out2        long
Out3        long
Out4        long
Out5        long
Out6        long
Out7        long
Out8        long
OutHolder   long

address     long          %0111_1111                  ' %0101_0000
ch1         long          0
ch2         long          %0000_0001
ch3         long          %0000_0010
ch4         long          %0000_0011
ch5         long          %0000_0100
ch6         long          %0000_0101
ch7         long          %0000_0110
ch8         long          %0000_0111

i2cSDA      long          %0000_1000         '3
i2cSDL      long          %0001_0000         '4

CkState  long          0
DtState   long          0
clkTime     long          80000
off_time    long          40000
idx         long          8
idxL        long          24
shiftR      long          32

time        res           1
t1          res           1

its hardly finished I am just trying to output the address to get started and then I will loop through all the channels and data that will be in outputs. its an 8 channel 8 bit DAC.
«1

Comments

  • ratronicratronic Posts: 1,451
    edited 2010-09-27 13:20
    Rick_H - what bit are you trying to isolate?
  • Rick_HRick_H Posts: 116
    edited 2010-09-27 13:25
    each bit in the address byte, I shift it left to msb and then right to lsb to clear all other bits. each djnz should get each bit in 8 passes.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-09-27 13:33
    You dont need to isolate a data bit to do the output
    heres an example of how I did it. Data starts as the i2c data byte to output, shift left for each bit to output. Test the 9th bit and set the carry flag and use the muxnc instruction to output the carry flag. The whole thing is then loops the right number of times, setting and resetting SCL correctly. I assume a pull up but you can use muxnc with outa instead
                            shl     data, #1               ' Shift left one bit
                            test    data, #$100   wc   ' Check MSB
                            muxnc   dira, sdamask      ' Set SDA HIGH if not zero
    
  • Rick_HRick_H Posts: 116
    edited 2010-09-27 13:49
    ahh cool, I was wondering how the mux worked. I need to play with it a bit I think.
  • Rick_HRick_H Posts: 116
    edited 2010-09-27 14:04
    wouldn't that give LSB first?
  • TimmooreTimmoore Posts: 1,031
    edited 2010-09-27 14:45
    The test instruciton is looking at the msb.
  • Rick_HRick_H Posts: 116
    edited 2010-09-27 15:17
    yes, I understand your code. Thank you, someone else has deleted their post with an example.
  • ratronicratronic Posts: 1,451
    edited 2010-09-27 15:20
    I deleted mine because it was for rs232 serial not for i2c
  • Rick_HRick_H Posts: 116
    edited 2010-09-27 16:58
    whats the fastsest anyone has gotten I2C clock working with a prop?
  • AleAle Posts: 2,363
    edited 2010-09-27 23:38
    Rick_H:

    The clock can be as high as 5 MHz or so, but the devices are limited to 1 MHz (IIRC) the fastest. Most devices operate in the 100 to 400 kHz region.
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 06:07
    Thanks Ale, I was planing on around 200kHz so that fits well.

    I am still having trouble getting this to work

    hear is my updated code, I really thought this would work but the SDA pin is staying high.
    con
      
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    VAR
      long flag, amp[8], clock
      long cog
    
    PUB start : okay 
     
    okay := cog := cognew(@entry, @flag) + 1
    
    DAT
                              org                                   ' Sets the origin at zero for this point
    entry                     or      DIRA,     i2cSDA             ' Sets relevant pin to an output                          
                              xor     DIRA,     i2cSDL             ' Sets relevant pin to an output
                              
                              mov     time,     CNT                 ' Current clock loaded into time
                              add     time,     off_time            '
                                   
    AddressB                  mov     OutHolder,address              'move data to placeholder
    loop                      shl     OutHolder,#1                 'shift indexed bit to 9th bit
                              
                              
    clkloop                   waitcnt time,     off_time             ' clock time
                  
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1                   'set clock pin state indicator       
                              waitcnt time,     off_time             'wait 1/2 clock pulse
                              cmp     CkState,  #1      wz           'check for low clock pulse and alow data pin change on low
                if_z          jmp     #clkloop                       'if not = 0 then finish clock pulse
                
                              
                              test     OutHolder,#%1_000_0000 wc             'check data pin state to data bit
    
                              
    pinSDL                    muxnc     OUTA,     i2cSDA               ' toggle data pin
                              djnz    idx,      #loop                ' repeate for each bit in a byte
                              mov     idx,      #8                   ' reset idx
                              
                              jmp     #AddressB                      'resend address
    
    
    
    Out1        long          
    Out2        long
    Out3        long
    Out4        long
    Out5        long
    Out6        long
    Out7        long
    Out8        long
    OutHolder   long
    
    address     long          %0101_0000                  ' %0101_0000
    ch1         long          0
    ch2         long          %0000_0001
    ch3         long          %0000_0010
    ch4         long          %0000_0011
    ch5         long          %0000_0100
    ch6         long          %0000_0101
    ch7         long          %0000_0110
    ch8         long          %0000_0111
    
    i2cSDA      long          %0000_1000         '3
    i2cSDL      long          %0001_0000         '4
    
    CkState  long          0
    DtState   long          0
    clkTime     long          80000
    off_time    long          40000
    idx         long          8
    idxL        long          24
    shiftR      long          32
    
    time        res           1
    t1          res           1
    
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 06:41
    I know I'm close but I just can't seam to get the pulse from the looping through the byte.

    if I just pulse the data line with no if or muxnc its a perfect on off signal but I cant seem to parse the holder data as my output.
  • ratronicratronic Posts: 1,451
    edited 2010-09-28 08:51
    Rick_H - I have never coded for i2c in assembly but with that said, the example timmoore showed you yesterday is using a pull up on the sda pin. follow the example he showed you. I made two changes in the code you just posted to make it shift the bits out.
    con
     
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    VAR
      long flag, amp[8], clock
      long cog
    PUB start : okay 
     
    okay := cog := cognew(@entry, @flag) + 1
    DAT
                              org                                   ' Sets the origin at zero for this point
    entry                     'or      DIRA,     i2cSDA             ' Sets relevant pin to an output                          
                              xor     DIRA,     i2cSDL             ' Sets relevant pin to an output
     
                              mov     time,     CNT                 ' Current clock loaded into time
                              add     time,     off_time            '
     
    AddressB                  mov     OutHolder,address              'move data to placeholder
    loop                      shl     OutHolder,#1                 'shift indexed bit to 9th bit
     
     
    clkloop                   waitcnt time,     off_time             ' clock time
     
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1                   'set clock pin state indicator       
                              waitcnt time,     off_time             'wait 1/2 clock pulse
                              cmp     CkState,  #1      wz           'check for low clock pulse and alow data pin change on low
                if_z          jmp     #clkloop                       'if not = 0 then finish clock pulse
     
     
                              test     OutHolder,#%1_000_0000 wc             'check data pin state to data bit
     
    pinSDL                    muxnc     dira,     i2cSDA               ' toggle data pin
                              djnz    idx,      #loop                ' repeate for each bit in a byte
                              mov     idx,      #8                   ' reset idx
     
                              jmp     #AddressB                      'resend address
     
    Out1        long          
    Out2        long
    Out3        long
    Out4        long
    Out5        long
    Out6        long
    Out7        long
    Out8        long
    OutHolder   long
    address     long          %0101_0000                  ' %0101_0000
    ch1         long          0
    ch2         long          %0000_0001
    ch3         long          %0000_0010
    ch4         long          %0000_0011
    ch5         long          %0000_0100
    ch6         long          %0000_0101
    ch7         long          %0000_0110
    ch8         long          %0000_0111
    i2cSDA      long          %0000_1000         '3
    i2cSDL      long          %0001_0000         '4
    CkState  long          0
    DtState   long          0
    clkTime     long          80000
    off_time    long          40000
    idx         long          8
    idxL        long          24
    shiftR      long          32
    time        res           1
    t1          res           1
    
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 09:36
    ok I commented out my dira line and changed my outa to dira on the i2cSDA line, added a pullup and I still get nothing. I'm not sure how changing source to sinking has anything to do with it. I am just looking at my pulses with a scope at the moment.
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 10:24
    It looks like the data bit isn't being shifted in, I change the muxnc to muxc and it went from low to high, so I must always be getting 0 in the c flag. Just can' seem to work this out.
  • ratronicratronic Posts: 1,451
    edited 2010-09-28 10:31
    Are you still constantly seeing a high - I checked with a dso and I see it ending up low. I haven't followed your code all the way through, just checked for action on the sda pin.
  • ratronicratronic Posts: 1,451
    edited 2010-09-28 10:34
    Post the latest code your working with.
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 10:37
    Ok i think I see a problem, its somewhere in the loop. I started up the data logger and after I load the ram I actualy get the correct pulse but it dosnt repeat for some reason.

    I'm getting a 1 on pulse 1 , a 1 on pulse 2, a 0 on pulse 3, a 1 on pulse 4 and then it just stays at 0 forever.

    I uncommented the first init of dira with i2cSDA and I get what I expect, 0101 but then it stays 0 forever
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 10:38
    con
     
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    VAR
      long flag, amp[8], clock
      long cog
    PUB start : okay 
     
    okay := cog := cognew(@entry, @flag) + 1
    DAT
                              org                                   ' Sets the origin at zero for this point
    entry                     or      DIRA,     i2cSDA             ' Sets relevant pin to an output                          
                              xor     DIRA,     i2cSDL             ' Sets relevant pin to an output
     
                              mov     time,     CNT                 ' Current clock loaded into time
                              add     time,     off_time            '
     
    AddressB                  mov     OutHolder,address              'move data to placeholder
    loop                      shl     OutHolder,#1                 'shift indexed bit to 9th bit
     
     
    clkloop                   waitcnt time,     off_time             ' clock time
     
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1                   'set clock pin state indicator       
                              waitcnt time,     off_time             'wait 1/2 clock pulse
                              cmp     CkState,  #1      wz           'check for low clock pulse and alow data pin change on low
                if_z          jmp     #clkloop                       'if not = 0 then finish clock pulse
     
     
                              test     OutHolder,#%1_000_0000 wc             'check data pin state to data bit
     
    pinSDL                    muxnc     dira,     i2cSDA               ' toggle data pin
                              djnz    idx,      #loop                ' repeate for each bit in a byte
                              mov     idx,      #8                   ' reset idx
     
                              jmp     #AddressB                      'resend address
     
    Out1        long          
    Out2        long
    Out3        long
    Out4        long
    Out5        long
    Out6        long
    Out7        long
    Out8        long
    OutHolder   long
    address     long          %0101_0000                  ' %0101_0000
    ch1         long          0
    ch2         long          %0000_0001
    ch3         long          %0000_0010
    ch4         long          %0000_0011
    ch5         long          %0000_0100
    ch6         long          %0000_0101
    ch7         long          %0000_0110
    ch8         long          %0000_0111
    i2cSDA      long          %0000_1000         '3
    i2cSDL      long          %0001_0000         '4
    CkState  long          0
    DtState   long          0
    clkTime     long          80000
    off_time    long          40000
    idx         long          8
    idxL        long          24
    shiftR      long          32
    time        res           1
    t1          res           1
    
  • AribaAriba Posts: 2,690
    edited 2010-09-28 10:55
    Rick

    The problem are these definitions:
    Out1        long          
    Out2        long
    Out3        long
    Out4        long
    Out5        long
    Out6        long
    Out7        long
    Out8        long
    OutHolder   long
    address     long          %0101_0000                  ' %0101_0000
    

    A long without a value just means "long align" but reserves no cog ram.
    So all the registers Out1..address have the same cog address.

    Change it to:
    Out1        long          0
    Out2        long          0
    Out3        long          0
    Out4        long          0
    Out5        long          0
    Out6        long          0
    Out7        long          0
    Out8        long          0
    OutHolder   long        0
    address     long          %0101_0000                  ' %0101_0000
    
    and it will work...
    (I had to use PASD to find this)

    Andy
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 11:04
    ahh very cool, thank you. checking it again in a second.
  • ratronicratronic Posts: 1,451
    edited 2010-09-28 11:05
    Rick the reason your code isn't repeatedly changing the sda line is you need to change it back to a input after you change it to a output - and ariba is right you need to define any longs you declare.

    edit: the sda line
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 11:10
    HAHA, that will learn me. Works as expected. Thanks guys.
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 11:28
    So what is asm doing with no data in the declared longs ? also whats pasd?
  • AribaAriba Posts: 2,690
    edited 2010-09-28 13:03
    PASD is an Assembly Debugger with Windows-GUI.
    http://propeller.wikispaces.com/PASD

    A long without data forces the next data to be placed at a long aligned address, that is an address which is a multiple of 4. This is useful if you need to be sure that some byte or word data starts at a long address. If this is already the case as in your code, then it does nothing.
    So OutHolder and address was the same register with two different names. After some left shifts of OutHolder, address is zero, because the shift instruction shifts zeroes in.

    Andy
  • Rick_HRick_H Posts: 116
    edited 2010-09-28 17:57
    cool thanks for the explanation, gona check out the debugger, I tried gear but haven't read the documentation and don't have a clue as to how to debug with it.

    I'm heaving a new problem now, hopefully I can get the debugger working.
    Basically I have all my loops for address, channel , data with an ack bit each and a start and stop routine. Oddly enough the MSB is always 0 in any of the bytes I am shifting into.
  • Rick_HRick_H Posts: 116
    edited 2010-09-29 19:02
    OK I have the debugger installed and working.

    The problem I am looking for is it all ways passes a 0 on the first bit shifted in. I am looking at the cog memory and stepping through the code and I can see the data getting updated but i'm not sure how exactly to pinpoint the problem. I can see the holder var get updated and shifted but I am kinda stuck their atm.

    Any suggestions on what to look for?

    o and kudos on the debugger, its way bad azz.
  • ratronicratronic Posts: 1,451
    edited 2010-09-29 22:34
    Rick - can't help with out seeing your latest code.
  • Rick_HRick_H Posts: 116
    edited 2010-09-30 04:31
    hear is the updated test code, I am not using pullups on the buss so I am using muxc instead of muxnc and outa instead of dira. the 9th bit is for ack but I am not using it either, I just need a 0. so I shift left 9 for the 9th 0.

    other than not getting a 0 in the msb the code works perfectly.
    con
      
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    VAR
      long flag, amp[8], clock
      long cog
    
    
    PUB start : okay 
    flag := 0
    amp[0] :=1
    amp[1] :=2
    amp[2] :=3
    amp[3] :=4
    amp[4] :=5
    amp[5] :=6
    amp[6] :=7
    amp[7] :=8
    clock := 250
    waitcnt(clkfreq + cnt)
    dbg.start(31,30,@entry)
    okay := cog := cognew(@entry, @flag) + 1
    repeat
        
        waitcnt(clkfreq/2000 + cnt)
            flag := 2
            amp[0] +=1
            amp[1] +=2
            amp[2] +=3
            amp[3] +=4
            amp[4] +=5
            amp[5] +=6
            amp[6] +=7
            amp[7] +=8
    DAT
                              org
    entry                                                            ' Sets the origin at zero for this point
                                                   
                         or      DIRA,     i2cSDA                    ' Sets relevant pin to an output                          
                              xor     DIRA,     i2cSDL               ' Sets relevant pin to an output
                              xor     OUTA,     i2cSDL
                              xor     OUTA,     i2cSDA
                              xor     CkState,  #1
                              mov     time,     CNT                  ' Current clock loaded into time
                              add     time,     off_time
    
    loadData                  mov     t1,       par
                              rdlong  asmflag,     t1
                              test    asmflag,     #2        wz
                              waitcnt time,     clkTime
                if_z         jmp     #loadData
                              add     t1,       #4
                              rdlong  out1,     t1
                              add     t1,       #4
                              rdlong  out2,     t1
                              add     t1,       #4
                              rdlong  out3,     t1
                              add     t1,       #4
                              rdlong  out4,     t1
                              add     t1,       #4
                              rdlong  out5,     t1
                              add     t1,       #4
                              rdlong  out6,     t1
                              add     t1,       #4
                              rdlong  out7,     t1
                              add     t1,       #4
                              rdlong  out8,     t1
                              add     t1,       #4
                              rdlong  off_time, t1
                              
                              wrlong  ch1,      par
                              
                              mov     time,     CNT                 ' Current clock loaded into time
                              add     time,     off_time
                              call    #starti2c
                                   
    AddressB                  mov     OutHolder,address
                              mov     t1,       #0              
                              jmp     #loop
                              
    ch1Add                    mov     OutHolder,ch1
                              mov     t1,       #1
                              jmp     #loop
    
    ch1data                    mov     OutHolder,Out1
                              mov     t1,       #2
                              jmp     #loop
                              
    ch2Add                    mov     OutHolder,ch2
                              mov     t1,       #3
                              jmp     #loop
    
    ch2data                    mov    OutHolder,Out2
                              mov     t1,       #4
                              jmp     #loop
    
    ch3Add                    mov     OutHolder,ch3
                              mov     t1,       #5
                              jmp     #loop
    
    ch3data                    mov    OutHolder,Out3
                              mov     t1,       #6
                              jmp     #loop
    
    ch4Add                    mov     OutHolder,ch4
                              mov     t1,       #7
                              jmp     #loop
    
    ch4data                    mov    OutHolder,Out4
                              mov     t1,       #8
                              jmp     #loop
    
    ch5Add                    mov     OutHolder,ch5
                              mov     t1,       #9
                              jmp     #loop
    
    ch5data                    mov    OutHolder,Out5
                              mov     t1,       #10
                              jmp     #loop
    
    ch6Add                    mov     OutHolder,ch6
                              mov     t1,       #11
                              jmp     #loop
    
    ch6data                    mov    OutHolder,Out6
                              mov     t1,       #12
                              jmp     #loop
    
    ch7Add                    mov     OutHolder,ch7
                              mov     t1,       #13
                              jmp     #loop
    
    ch7data                    mov    OutHolder,Out7
                              mov     t1,       #14
                              jmp     #loop
    
    ch8Add                    mov     OutHolder,ch8
                              mov     t1,       #15
                              jmp     #loop
    
    ch8data                    mov    OutHolder,Out8
                              mov     t1,       #16
                              jmp     #loop
    
    loop                      shl     OutHolder,#1                   'shift indexed bit to 9th bit
                              
                              
    clkloop                   waitcnt time,     off_time             ' clock time
                  
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1                   'set clock pin state indicator       
                              waitcnt time,     off_time             'wait 1/2 clock pulse
                              cmp     CkState,  #1      wz           'check for low clock pulse and alow data pin change on low
                if_z          jmp     #clkloop                       'if not = 0 then finish clock pulse
                
                              
                              test    OutHolder,#%1_000_0000 wc             'check data pin state to data bit
                              
                              
    pinSDA                    muxc    OUTA,     i2cSDA               ' toggle data pin
                              djnz    idx,      #loop                ' repeate for each bit in a byte
                              mov     idx,      #9                   ' reset idx
                                                 
                              cmp     t1,  #0      wz
                if_z          jmp     #ch1Add                   
                              cmp     t1,  #1      wz
                if_z          jmp     #ch1data
                              cmp     t1,  #2      wz
                if_z          jmp     #ch2Add
                              cmp     t1,  #3      wz
                if_z          jmp     #ch2data
                              cmp     t1,  #4      wz
                if_z          jmp     #ch3Add
                              cmp     t1,  #5      wz
                if_z          jmp     #ch3data
                              cmp     t1,  #6      wz
                if_z          jmp     #ch4Add
                              cmp     t1,  #7      wz
                if_z          jmp     #ch4data
                              cmp     t1,  #8      wz
                if_z          jmp     #ch5Add
                              cmp     t1,  #9      wz
                if_z          jmp     #ch5data
                              cmp     t1,  #10      wz
                if_z          jmp     #ch6Add
                              cmp     t1,  #11      wz
                if_z          jmp     #ch6data
                              cmp     t1,  #12      wz
                if_z          jmp     #ch7Add
                              cmp     t1,  #13      wz
                if_z          jmp     #ch7data
                              cmp     t1,  #14      wz
                if_z          jmp     #ch8Add
                              cmp     t1,  #15      wz
                if_z          jmp     #ch8data
                              cmp     t1,  #16      wz
                              call    #stopi2c
                if_z          jmp     #loadData                      
    
    starti2c                  waitcnt time,     off_time             ' clock time              
                              xor     OUTA,     i2cSDA               'toggle clock
                              waitcnt time,     off_time             ' clock time
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1                   'set clock pin state indicator       
                              waitcnt time,     off_time                          
    starti2c_ret              ret
    
    stopi2c                   waitcnt time,     off_time            '
                              xor     OUTA,     i2cSDL               'toggle clock
                              xor     CkState,  #1
                              waitcnt time,     off_time
                              xor     OUTA,     i2cSDA               'toggle clock       
                              waitcnt time,     off_time                          
    stopi2c_ret              ret
                       
    
    Out1        long          %1111_1111
    Out2        long          %1111_1110
    Out3        long          %1111_1101
    Out4        long          %1111_1011
    Out5        long          %1111_0111
    Out6        long          %1110_1111
    Out7        long          %1101_1111
    Out8        long          %1011_1111
    OutHolder   long          %0111_1111
    
    address     long          %1101_0000                  ' %0101_0000
    ch1         long          0
    ch2         long          %0000_0001
    ch3         long          %0000_0010
    ch4         long          %0000_0011
    ch5         long          %0000_0100
    ch6         long          %0000_0101
    ch7         long          %0000_0110
    ch8         long          %0000_0111
    
    i2cSDA      long          %0000_1000         '3
    i2cSDL      long          %0001_0000         '4
    
    CkState     long          0
    DtState     long          0
    clkTime     long          8000
    off_time    long          400000
    idx         long          9
    
    asmflag        long       0
    time        res           1
    t1          res           1
    
  • AribaAriba Posts: 2,690
    edited 2010-09-30 05:31
    Rick

    You shift first the OutHolder left:
    loop            shl     OutHolder,#1          'shift indexed bit
              ...
    
    and then test bit 7
    test    OutHolder,#%1_000_0000 wc     'check data pin state to data bit
    
    so the MSB is never checked
    Perhaps you intended: test OutHolder,#%1_0000_0000 wc

    Andy

    Edit:
    You see the Carry bit in PASD left bottom in the status bar, updated after each step.
Sign In or Register to comment.