Shop OBEX P1 Docs P2 Docs Learn Events
Having trouble running both serial terminal and full duplex serial at the same time — Parallax Forums

Having trouble running both serial terminal and full duplex serial at the same time

tuffstufftuffstuff Posts: 24
edited 2013-08-22 22:45 in Propeller 1
I have found an issue that is perplexing me. I have some working code that breaks when I comment out one line and I'm not sure why. The end goal is a real time midi parser. My current stage is trying to print to the serial terminal the midi recording mode (on or off) while reading in midi data via FullDuplexSerial. Record mode is toggled via a Yamaha sustain pedal. The code below does not toggle to record mode when I hit the pedal. Record is allways off. Here is my code:

CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

OBJ
  pst   : "Parallax Serial Terminal"
  midi  : "FullDuplexSerial"

VAR
  LONG stack[128]
  LONG midiseq[64]
  BYTE rectog[1]
  BYTE recstate[1]

PUB Main | mbyte, track, counter

  cognew(PetalBounce, @stack)
  pst.Start(115200)
  midi.start( 0, 1, %0000, 31250 )
                 
  repeat                                 
    RecordON
    pst.dec(recstate)
    
PUB MidiRecord: midibyte

  pst.str(string(" testMidiRecord "))                      'indicate the MidiRecord has began
  if (midibyte := midi.rxcheck) <> -1
    return midibyte


PUB RecordON
                  
    repeat while rectog == 0                        
      recstate := 0
      pst.str(string(" rec OFF "))
    repeat while rectog == 1
      recstate := 1
      pst.str(string(" rec ON  "))
    repeat while rectog == 0
      recstate := 1
      pst.str(string(" rec ON  "))
    repeat while rectog == 1
      recstate := 0
      pst.str(string(" rec OFF "))

PUB PetalBounce | counter, val

    repeat                  
      if (val := INA[1]) == 0
        rectog := 1  
        counter := 0
        repeat while counter <> 400
          if INA[1] == 1                    
            counter ++
          if INA[1] == 0            
            counter := 0        
      else
        rectog := 0

But when I comment out the "midi.start( 0, 1, %0000, 31250 )" line it works fine. Like so:
...
PUB Main | mbyte, track, counter

  cognew(PetalBounce, @stack)
  pst.Start(115200)
  'midi.start( 0, 1, %0000, 31250 )
                 
  repeat                                 
    RecordON
    pst.dec(recstate)
...

Whats the deal? Thanks!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-22 22:38
    Are you sure you have the I/O pins specified properly. When you start midi., you're setting up pin 0 as the receive input and pin 1 as the transmit output. PetalBounce is monitoring the output of midi. When you comment out midi.start, pin 1 is left as an input pin. Maybe you want to swap the pin numbers in the midi.start statement?
  • tuffstufftuffstuff Posts: 24
    edited 2013-08-22 22:45
    Wow, great forum! That was it! Even though midi-in is one way I overlooked the fact that FullDuplexSerial is not.

    Thanks Mike!
Sign In or Register to comment.