In SX Microcontrollers, SX/B Compiler and SX-Key Tool, spacejunk wrote: A quick update, I have consolidated most af the variables into arrays. This seems to have solved the problem for the time being. Thanks for the help Jonny Mac. Here is the updated code for anyone interested (only the modified parts): [code] ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX48, OSCHS1 FREQ 20_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- 'Motor Pins PWMPinR PIN RD.1 'Pin used by interrupt, right motor PWMPinL PIN RD.2 'Pin used by interrupt, left motor DirPinR PIN RD.0 'Direction pins, set 1 for forward, 0 for reverse DirPinL PIN RD.3 'Line Sensor Pins rLine PIN RB.3 SCHMITT 'Right line sensor, active high lLine PIN RB.6 SCHMITT 'Left line sensor, active high 'Object Sensor Pins lSeek PIN RB.7 'Left front object sensor, active low rSeek PIN RB.4 'Right front object sensor, active low lSideSeek PIN RE.1 'Left side object sensor, active low rSideSeek PIN RE.0 'Right side object sensor, active low 'Close Proximity Sensors FrontProx PIN RB.5 'Front ProxDot, active low BackProx PIN RD.7 'Rear ProxDot, active low 'Control Buttons StartButton PIN RA.2 'Press to start routine (top button) NextButton PIN RA.3 'Cycle routines (bottom button) 'I2C EEPROM Pins SDA PIN RD.4 'Data line SCL PIN RD.5 'Clock out 'ADC SPI Pins 'ADC pinout incorrect, currently not used 'CS pin needs to be controlled, in Rev. G, tied to VSS 'Fixed in current circuit (Rev. H) design CLK PIN RE.2 'Clock signal Dout PIN RE.3 'Data out pin Din PIN RE.4 'Data in pin 'Accelerometer Pins Yacl PIN RB.0 'Y axis, pulse width Xacl PIN RB.1 'X axis, pulse width 'Serial Out (RS232 level) For Debugging RX PIN RA.1 'Serial debug recieve TX PIN RA.0 'Serial debug transmit 'Unused Pins RB_Unused PIN RB.2 PULLUP 'Set weak internal pullups RD_Unused PIN RD.6 PULLUP 'To keep unused pins from drifting RE_Unused1 PIN RE.5 PULLUP RE_Unused2 PIN RE.6 PULLUP RE_Unused3 PIN RE.7 PULLUP ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Baud CON "N38400" 'Serial Baud rate, 38400, Inverted True CON 1 'Constants used by state machine False CON 2 ' ------------------------------------- ' Seven Segment Numbers ' ------------------------------------- 'Table of seven segment display numbers 'Zero is on, one is off NumberOne CON %01011111 NumberTwo CON %00100011 NumberThree CON %00000111 NumberFour CON %01001101 NumberFive CON %10000101 NumberSix CON %10000001 NumberSeven CON %00011111 NumberEight CON %00000001 NumberNine CON %00001101 NumberZero CON %00010001 LetterP CON %00101001 LetterD CON %01000011 ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- PWMArray VAR Byte(3) PWMCount VAR PWMArray(0) 'PWM variables, used by interrupt PWMValueR VAR PWMArray(1) PWMValueL VAR PWMArray(2) Temp VAR Byte 'General work/counter SensFlags VAR Byte 'Order (LSB first) - Edge_L, Edge_R, Obj_L, Obj_R, Obj_LS, Obj_RS, Prox_F, Prox_R CurPos VAR Byte 'Seven segment display work variables CurNum VAR Byte 'DirR VAR Bit Currently unused, may be used to improve motor control 'DirL VAR Bit DebugByte VAR Byte tempArray VAR Byte(5) temp1 VAR tempArray(0) 'Subroutine work vars temp2 VAR tempArray(1) temp3 VAR tempArray(2) temp4 VAR tempArray(3) temp5 VAR tempArray(4) temp6 VAR Bit StateArray VAR Byte(3) CurrentState VAR StateArray(0) 'State machine current state variable NextState VAR StateArray(1) 'State machine next state variable, used for transitions CycleCount VAR StateArray(2) 'State machine cycle counter, used for timing InitState VAR Bit 'State machine initiate state flag, 1 when state change LineFlagL VAR SensFlags.0 'SensFlags Var broken out into individual variables LineFlagR VAR SensFlags.1 ObjFlagL VAR SensFlags.2 ObjFlagR VAR SensFlags.3 ObjFlagSL VAR SensFlags.4 ObjFlagSR VAR SensFlags.5 ProxFlagF VAR SensFlags.6 ProxFlagR VAR SensFlags.7 AddressPointer VAR Byte AddressVal VAR Word [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=305715#m305763 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)