Shop OBEX P1 Docs P2 Docs Learn Events
Struggling with simple thing — Parallax Forums

Struggling with simple thing

HighwayRobHighwayRob Posts: 5
edited 2010-10-22 14:42 in Propeller 1
I am struggling with a simple thing. I am using the FullDuplexSerial Debugger.

The PC[index] variable in the code segment below does not appear to get incremented when I use the ++. The ser.dec(PC[index],1) always displays zero.

Is this an issue with the FullDuplex deugger program?

Is this a valid way of doing this? Really odd, is that it seems to work when the FullDuplex program is not used! I was using the fullduplex program to verify all is good.

I need 18 accumulators to do some counting if an alarm is detected. I would rather not create 18 separate variables and use a CASE statement, but I will if I have to.


VAR
Byte PC[17] 'Byte array for the Wait Counter of the Alarm Delay

'Here is the problematic code

if AS == ina[index] ' and If Alarm is on
if PC[index] <= AD
PC[index]++
ser.tx(13)
ser.str(string("incremented PC = "))
ser.dec(PC[index],1)
else
PC[index]:=0 ' otherwise reset to zero
ser.tx(13)
ser.str(string("zeroed PC"))

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-22 10:44
    Please use the "code" tags that you get by selecting your code text and clicking on the "#" button. When you paste code into a message, you lose the indenting and that may be why your code doesn't work as expected.

    The "++" operator works and FullDuplexSerial works, so it must be something else.

    You show the call to "ser.dec(PC[index],1)" which will not compile since ser.dec takes only a single argument, so I'm not sure what your actual code looks like. This is another reason why you need to post your actual code.
  • AribaAriba Posts: 2,690
    edited 2010-10-22 14:42
    if PC[index] <= AD does not what you think. Try it with
    if PC[index] =< AD

    Andy
Sign In or Register to comment.