Serin2 and Button command


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    some things can cause this. Let's look this snip

    Code:
    IF AL=88 THEN 
         IF SONDU=1 THEN ARA 'if already off then ara
         GOSUB SON 'gosub off
         GOTO START
    ENDIF
    You exit several time from a IF THEN and/or a nested IF THEN ELSE with a goto... not a good practice. You probably overflow the stack pointer.

    as i read SONDU will be 0 or 1 so
    Code:
    ReturnToStart var Bit
    
    
    Start:
    ReturnToStart = 0
    
    IF AL=88 THEN 
         IF SONDU=0 THEN 
              GOSUB SON 'gosub off
         endif
         ReturnToStart = 1
    ENDIF
    if ReturnToStart then GotoStart
    about the BUTTON statement... i'm not a fan of this statement. i'll prefer do 2-3 lines myself.

    Let's say i want to monitor a pushButon on PORTA.1
    Code:
    TRISA.1=1
    PushButton VAR PORTA.1
    start:
         If PushButton then    ' Pushbutton active 
              While PushButton ' wait untill it's release
              Wend
              Pause 50 ' debounce time
              Gosub XYZ
         endif
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Aug 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Dear Steve,
    Thank you for the tricks. You right I checked the program again and I saw that there are a lot of cunfusions. It was working but as you have said the reason can be the stack due to that cınfusions.Anyhow, I changed the program to make one loop only. I taken out all the zig-zags in the program. I did not yet tried. I was busy. I will try it within two days and let you know the result.

    It would be good idea if I can check the program with one debugger. It is a pity that I have not mcs plus. By the way I would see where the program was going without touching the button command.

    Thanks again
    ERO

  3. #3
    Join Date
    Aug 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Steve,

    Yesterday evening, I tested all the possibilities again after I made a new program which is only one loop. It was checking the button first after it was passing to SERIN2 command and passing to control what was arrived by SERIN2. Anyhow I have to tell you that the serin or serin2 command does not work with any button control. I tested all the timeout figures starting from 2 ms up to 2000 ms. I am sure there is a bug in the compiler.
    I tested again the HSERIN command by making some changing on the pcb and I saw that it is working very well. Today I will change all the PCB and the program for working with HSERIN command.

    I wanted to give you again the result of my work which can be intersting for other people.
    Thanks again for your helps.

    Regards
    Ero

Members who have read this thread : 0

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