I might be totally wrong...not that familiar with C...but to me this means:Code:void WriteCMD( uint CMD ) <-uint CMD takes in an unsigned integer { uchar n=16; <-unsigned character (byte) set to 16 SCK=0; <- SCK to logic low nSEL=0; <- nSEL to logic low while(n--) <- while/wend loop, n gets decremented by 1 each time thru { if(CMD&0x8000) <- if high bit of CMD is set then Write1(); <-call the Write1() sub else Write0(); <-otherwise do this one CMD=CMD<<1; <-shift it left by one } SCK=0; <- SCK to logic low nSEL=1; <- nSEL to logic high }
And your issue might've been that you didn't turn the nSEL line on/off before writing out to the port...unless you didn't include that part in the posts.Code:WriteCMD: n = 16 : SCK = 0 : nSEL = 0 for nn = 16 to 0 step -1 if cmd.15 = 1 then gosub write1 else gosub write0 endif cmd = cmd << 1 : sck = 0 : nSel = 1 : return Write0: SDI = 0 : SCK = 0 : pauseus 16 : SCK = 1 : return Write1: SDI = 1 : SCK = 0 : pauseus 16 : SCK = 1 : return




Bookmarks