Shop OBEX P1 Docs P2 Docs Learn Events
printing midi data to serial terminal - troubleshooting — Parallax Forums

printing midi data to serial terminal - troubleshooting

tuffstufftuffstuff Posts: 24
edited 2013-08-07 17:19 in Propeller 1
Hi all,

I am trying to print midi data on pin 0 to my serial terminal. I think I may have the wrong type of optocoupler in my circuit, but I thought I would run my code by you all before I buy new ones. Because I'm reading and writing serial data from two different sources I thought maybe there could be an issues with different baud speeds in my code. Here is what I have:
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

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

PUB main

  pst.Start(115200)
  midi.start( 0, 1, 00, 31250 ) 

  repeat
    if midi.rxcheck <> -1
      pst.dec(midi.rxcheck)
      pst.str(string(" "))   

Let me know if this looks fine to you all for my purposes. If so, than I know it's my midi schematic. I should mention that my serical code is reading all -1 unless I put the if block.

Thanks!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-07 07:39
    In your repeat loop, you're discarding the first MIDI byte read in and probably displaying -1 because there isn't a 2nd byte yet. Try defining a local variable in main and using it like this:
    PUB main | i
    ' stuff
    if (i := midi.rxcheck) <> -1
       pst.dec(i)
    
  • tuffstufftuffstuff Posts: 24
    edited 2013-08-07 10:03
    So my code is currently printing every other byte instead of every byte?

    I'll try this out when I get home.
  • AribaAriba Posts: 2,690
    edited 2013-08-07 10:26
    To make it easier you can change the repeat loop to:
      repeat
        pst.hex(midi.rx,2)
        pst.char(" ")
    
    Hex makes more sense with MIDI data than Dec

    Andy
  • tuffstufftuffstuff Posts: 24
    edited 2013-08-07 17:19
    Ah it works! Assigning the variable in the if statement and viewing in hex makes it easier although the real problem was with my schematic. Different schematics for MIDI show either as cable view or jack view and never specify. I had my pins switched on the MIDI in jack.

    Thanks for the tips!
Sign In or Register to comment.