button press AND hserout issues?!


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    27

    Default button press AND hserout issues?!

    So... I dug out my ICD2 and selection of pics, to build myself a MIDI foot controller. Not having played with MIDI before, I set up a 16f628a, and tried the following:

    DEFINE HSER_TXSTA 24H
    DEFINE HSER_BAUD 31250

    main:

    [set relevant ports and CMCON, etc...]

    loop:
    hserout [144,90,90]
    goto loop

    Voila! My MIDI analyser shows note on, channel 1, regular as clockwork. Next, I need to send differing messages dependent on one of [n] push-to-make footswitches, so I tried:

    if not porta.1 then
    hserout [144,90,90]
    endif

    FAIL! Whereas the analyser was consistent before, now it fails every so often, showing error messages/system reset errors, etc., which leads me to believe there are timing issues with the USART that the if...then and porta.0 test is causing.


    I don't want to write a hserout equivalent in assembler, as that's the whole point of using PicBasic Pro, but the timing issues and the button press test are making what should have been a simple project quite frustrating...

    I feel that there's not enough documentation available which explains precisely which resources a given command uses, borne out of other frustrating isues I've had with timers, serial LCD display, etc...

    Can anybody shed any light on this, or is it back to assembler for this whole project???

    G
    Last edited by Giulio; - 29th July 2011 at 20:26. Reason: fixed one issue

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: button press AND hserout issues?!

    Have you turned of the analog on PORTA?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2005
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: button press AND hserout issues?!

    Yes, I didn't want to waste space by showing my initialisation code, but:

    CMCON = 7

    and to isolate the one switch for testing:

    TRISA = %00000010



    G

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: button press AND hserout issues?!

    if not porta.1 then
    hserout [144,90,90]
    endif

    FAIL! Whereas the analyser was consistent before, now it fails every so often, showing error messages/system reset errors, etc., which leads me to believe there are timing issues with the USART that the if...then and porta.0
    You may want to post your whole code...
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2005
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Re: button press AND hserout issues?!

    The porta.0 was a typo in my message - the code was exact. This works, every time, and doesn't skip a beat:


    define OSC 20

    DEFINE HSER_TXSTA 24H
    DEFINE HSER_BAUD 31250

    main:

    CMCON = 7
    TRISA = %00000010
    TRISB = 0


    loop:

    hserout [144,90,90]

    goto loop

    ;---------------------------------------

    This also works some of the time, but midi analyser shows 'error' periodically, and results are spurious:


    define OSC 20

    DEFINE HSER_TXSTA 24H
    DEFINE HSER_BAUD 31250

    main:

    CMCON = 7
    TRISA = %00000010
    TRISB = 0


    loop:

    if not porta.1 then
    hserout [144,90,90]
    endif

    goto loop

    ;-------------------------------------

    As I said, the if...then, and the test for button is most certainly doing something to the hserout command. I've tried putting a PAUSE [x] before and after and both before and after the hserout command, and it just slows things up, and still produces errors at the midi analyser... ???


    G

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: button press AND hserout issues?!

    Just for kicks, change the loop label to something other then loop. That is a keyword in later releases and maybe it is playing up on the IF?

    And maybe put a check after the HSEROUT to check if the transmission is done. Maybe the transmission is colliding with the next time through loop since there is nothing else to do? Of course that doesn't explain why the first one works.
    Last edited by cncmachineguy; - 30th July 2011 at 00:04.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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