Need Help with SX28 code efficiency (SHIFTOUT, READ, temp variables?, etc.) in
T&E Engineer
Posts: 1,396
I have working code but need to have it run faster·and more efficient. How can I improve this
(Mainly trying to have a subroutine or something for the SHIFTOUT statements and possibly READ statements - but don't know if I can call out Cpin and Dpin pin #s) What about combining the CpinX into a single one(?) like I did with A, B, and Latch:
(Mainly trying to have a subroutine or something for the SHIFTOUT statements and possibly READ statements - but don't know if I can call out Cpin and Dpin pin #s) What about combining the CpinX into a single one(?) like I did with A, B, and Latch:
' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- A PIN RA.0 OUTPUT ' A line (A pin 9) B PIN RA.1 OUTPUT ' B line (B pin 11) Latch PIN RA.2 OUTPUT ' latch outputs (STB pin 3) Cpin1 PIN RB.0 OUTPUT ' shift clock1 (CLK pin 1) Cpin2 PIN RB.1 OUTPUT ' shift clock2 (CLK pin 1) Cpin3 PIN RB.2 OUTPUT ' shift clock3 (CLK pin 1) Cpin4 PIN RB.3 OUTPUT ' shift clock4 (CLK pin 1) Cpin5 PIN RB.4 OUTPUT ' shift clock5 (CLK pin 1) Cpin6 PIN RB.5 OUTPUT ' shift clock6 (CLK pin 1) Dpin1 PIN RC.0 OUTPUT ' shift data1 (DG pin 7) Dpin2 PIN RC.1 OUTPUT ' shift data2 (DG pin 7) Dpin3 PIN RC.2 OUTPUT ' shift data3 (DG pin 7) Dpin4 PIN RC.3 OUTPUT ' shift data4 (DG pin 7) Dpin5 PIN RC.4 OUTPUT ' shift data5 (DG pin 7) Dpin6 PIN RC.5 OUTPUT ' shift data6 (DG pin 7) : : Main: HIGH A ' Turn off displays HIGH B For alpha = 0 TO 23 ' 0 - 23 for 1st odd row display READ ODD_ROW_1A + alpha, pattern ' read in the data SHIFTOUT Dpin1, Cpin1, MSBFIRST, pattern ' send the bits READ ODD_ROW_2A + alpha, pattern ' read in the data SHIFTOUT Dpin2, Cpin2, MSBFIRST, pattern ' send the bits READ ODD_ROW_1B + alpha, pattern ' read in the data SHIFTOUT Dpin3, Cpin3, MSBFIRST, pattern ' send the bits READ ODD_ROW_2B + alpha, pattern ' read in the data SHIFTOUT Dpin4, Cpin4, MSBFIRST, pattern ' send the bits READ ODD_ROW_1C + alpha, pattern ' read in the data SHIFTOUT Dpin5, Cpin5, MSBFIRST, pattern ' send the bits READ ODD_ROW_2C + alpha, pattern ' read in the data SHIFTOUT Dpin6, Cpin6, MSBFIRST, pattern ' send the bits NEXT alpha PULSOUT Latch, 1 ' transfer to outputs LOW B ' turn on odd rows PAUSEUS DelayTime HIGH A ' Repeat again for even rows HIGH B ' Turn off display For alpha = 0 TO 23 ' 0 - 23 for 1st even row display READ EVEN_ROW_1A + alpha, pattern ' read in the data SHIFTOUT Dpin1, Cpin1, MSBFIRST, pattern ' send the bits READ EVEN_ROW_2A + alpha, pattern ' read in the data SHIFTOUT Dpin2, Cpin2, MSBFIRST, pattern ' send the bits READ EVEN_ROW_1B + alpha, pattern ' read in the data SHIFTOUT Dpin3, Cpin3, MSBFIRST, pattern ' send the bits READ EVEN_ROW_2B + alpha, pattern ' read in the data SHIFTOUT Dpin4, Cpin4, MSBFIRST, pattern ' send the bits READ EVEN_ROW_1C + alpha, pattern ' read in the data SHIFTOUT Dpin5, Cpin5, MSBFIRST, pattern ' send the bits READ EVEN_ROW_2C + alpha, pattern ' read in the data SHIFTOUT Dpin6, Cpin6, MSBFIRST, pattern ' send the bits NEXT alpha PULSOUT Latch, 1 ' transfer to outputs LOW A ' turn on the even rows PAUSEUS DelayTime GOTO Main
Comments
I don't think with SX Basic you can do the pin assignments for SHIFTIN/OUT as variables. I know you definitely can not for SERIN/OUT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-MH
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA