Array -- something wrong?


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1

    Default Array -- something wrong?

    For the life of me, I can't figure out what is wrong with this code. This is just the start of a program where I check all the bytes in the serial port (DATAIN) --
    if the total = 0 then it just loops and an LED is off.

    If any of the bytes contain data (a 1 or greater) then the LED is on. Then, eventually on to do other stuff.

    Maybe it's the way I set up the array as I've never used one in picbasic before.

    The pause is in there so I can see the LED. Thanks for any help.


    DATAIN VAR BYTE[13]
    ADDUP VAR BYTE
    TOTAL VAR BYTE

    QUAL1 VAR BYTE
    QUAL2 VAR BYTE

    DATAIN= 0
    TOTAL = 0
    ADDUP = 0

    QUAL1 = 170
    QUAL2 = 255

    START:


    SerIn PORTA.0,N1200,[QUAL1,QUAL2],DATAIN

    FOR TOTAL = 1 TO 13
    ADDUP = ADDUP + DATAIN[TOTAL]
    NEXT TOTAL

    IF ADDUP = 0 THEN
    LOW PORTA.1 'DATA RECEIVED LED OFF
    GOTO START
    ENDIF

    IF ADDUP >= 1 THEN
    HIGH PORTA.1 'DATA RECEIVED LED ON
    ENDIF

    PAUSE 3000

    ADDUP = 0
    TOTAL = 0
    DATAIN = 0

    GOTO START

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    For a 13 element array it should be 0 to 12
    Keith

    www.diyha.co.uk
    www.kat5.tv

  3. #3


    Did you find this post helpful? Yes | No

    Default

    right after I posted I went to lay down -- and realized I put a one in there for some odd reason.

    thanks.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    oh well -- thought that was it myself but still no go -- yet I know my data is there on the serial port.

    on the PC end (using VBnet), I have my 2 qualifiers 170 and 255 then 13 bytes being sent. everything fine N1200, port etc.

    changed the PIC to --

    DATAIN[13]

    and (FOR 1 TO 12).

    still nothing?

  5. #5
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    What chip are you using ?

    does it have analogue ports ?
    Keith

    www.diyha.co.uk
    www.kat5.tv

  6. #6


    Did you find this post helpful? Yes | No

    Default

    16c72 (old timer)

    but I did ADCON1 = 7

    that changes porta to digital, right?

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts