Shop OBEX P1 Docs P2 Docs Learn Events
Help converting PBASIC program to Assembly or SX/B (Midi Time Code Project) — Parallax Forums

Help converting PBASIC program to Assembly or SX/B (Midi Time Code Project)

Mag748Mag748 Posts: 263
edited 2006-04-10 01:14 in BASIC Stamp
Hello everyone,
I have worked on a few projects over the past few years, none of which have ever been completed successfully. BUT, I am feeling good about this one. It has promise.
·
I will try to describe what exactly it is that I would like to do. First of all, I will explain some about MTC (Midi Time Code). MTC is the MIDI version of the SMPTE time code. It is sent using a midi cable the same way note on and note off commands are sent, which you·are probably·familiar with if you read any of the sample·programs that deal with MIDI. I want to read these signals (which all begin with $F1) and convert them to Hours, Minutes, Seconds, and Frames and then display them on a LED 7-segment display using the MAX7219. A little more is explained in the BSII program, so to see what the data actually looks like take a look at the comments. It is pretty straight forward. The only problem is the speed, which is quite important in this type of application.
·
So far, I have a good BSII program, which doesn't work at all, probably because I have not tested it fully, but more importantly because according to my calculations, and hopefully someone will confirm this, the BSII takes way to long to run, and misses all the info it needs. I calculated that it takes about 26 ms to run case 0 and 4, when, in reality, it only has about 4 and a half ms to do it (before the next bit of info comes along). (It does work if I simply send it the information it should be getting in the debug window) So, I must use my SX28 which I am sure is fast enough. But I do not know how to convert it from PBASIC to Assembly, and I have tried a simple SX/B program which initializes the MAX7219, but·it isn’t working either. So, if anyone would like to help me convert this PBASIC program into either assembly, or SX/B, I would love that. Of course this is asking a lot, but if anyone has any free time they are willing to spend looking at an interesting program, this is a great opportunity. I think the SX/B program should work, but it isn’t. And that is where I am stuck at the moment. I have attached the files below.
·
I certainly have not given up yet, and will continue to update this with progress I make, and will hopefully move the whole thing to the "projects" section once it is complete.
·
Thank you very much,
Marcus Garfunkel

Comments

  • ForrestForrest Posts: 1,341
    edited 2006-04-06 10:32
    Nuts and Volts #122 covers MIDI using SX/B on a SX28 processor - download it here www.parallax.com/html_pages/downloads/nvcolumns/Nuts_Volts_Downloads_V6.asp
  • Mag748Mag748 Posts: 263
    edited 2006-04-07 02:22
    Forrest, Thank you very much for that link. I hadn't seen it, and it is a huge help.
    -Marcus

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mag748Mag748 Posts: 263
    edited 2006-04-08 20:40
    Hello. I have edited the MIDI_CONTROL program to fit my needs, but have come to a problem. BTW, this thread should now be in the SX Forum I guess.

    Whenever I try to assemble the file, SXB.exe crashses and doesn't seem to finish writing the Source file. Then·a few·errors come up. The original MIDI_CONTROL file assembled fine, so I know it is something that I have done. I deleted much of the code that I wasn't needing, so I might have done something wrong, but there are no "errors" becuase the compiler crashes before finishing the SRC file. Anyone know what could be wrong?

    -Marcus Garfunkel

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mag748Mag748 Posts: 263
    edited 2006-04-08 23:42
    Hmm, I have figured out why it was crashing. The line

    temp2 = Frames - temp1
    

    was not valid I guess. I changed it to

    temp3 = Frmaes
    temp2 = temp3 - temp1
    

    and now it works

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mag748Mag748 Posts: 263
    edited 2006-04-09 17:28
    Do the ISR have to be changed at all if the clock frequency is different than 20 MHz?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-09 17:38
    Yes; change the prescaler to 1:1 and the RETURNINT value to 160 -- this will keep the ISR running at 8 us which it is designed to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Mag748Mag748 Posts: 263
    edited 2006-04-10 00:43
    Ok, I changed the Option register to $80 to make the prescaler 1:2 and set RETURNINT 200 to run at 50MHz. But is the ISR going to still think that the baud rate is 31.25 Kbs? It seems that the clock change would change the baud rate too.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-10 01:14
    If the combination of clock, prescaler, and RETURNINT causes the ISR to run every 8 us, then the baud will be 31.25k -- change any of those factors without adjusting the others and the baud rate will change.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.