Simple program to send MIDI messages w/the SX family @ 50 MHz
Without further adieu, here's the code. Yes, I know that's all you're here for... you could at least have bought me flowers or gotten me drunk. Pigs.
You may have to modify the formatting some, and you'll have to save it as a .src file. All that this program does is send middle C at maximum volume on channel one, then it loops indefinitely doing nothing, which is a pretty accurate metaphor for my life.Codice:;======================================================================= ;-------------------------- DEVICE DIRECTIVES -------------------------- DEVICE SX28,OSChs,TURBO IFDEF __SASM ;SASM Directives DEVICE STACKX,OPTIONX IRC_CAL IRC_SLOW ELSE ;Parallax Assember Directives DEVICE STACKX_OPTIONX ENDIF RESET Initialize ;------------------------------ VARIABLES ------------------------------ count1 EQU $08 count2 EQU $09 data equ $10 ;---------------------------- DEBUG SETTINGS --------------------------- FREQ 50_000_000 WATCH Count1,16,UDEC ;------------------------ INITIALIZATION ROUTINE ----------------------- Initialize ;Configure port settings mov rc, #%00000000 mov !rc, #$00 ;---------------------------- MAIN PROGRAM ----------------------------- Main mov !option, #%11000011 setb rc.0 call midi_wait call midi_wait mov data, #$90 ;midi channel one call midi_out mov data, #$3c ;middle c call midi_out mov data, #$7f ;maximum velocity call midi_out stall jmp stall midi_out mov count2, #$08 clrb rc.0 ;start bit call midi_wait midi_loop snb data.0 ;data bit setb rc.0 sb data.0 clrb rc.0 call midi_wait rr data djnz count2, midi_loop setb rc.0 ;stop bit call midi_wait ret midi_wait clr rtcc Loop cjne rtcc, #$62, loop ret
As you'll probably notice, I'm using the RTCC counter to time the MIDI bit length; this is for MIDI output buffering. The way that I'd implement it is to make a table (buffer) where midi notes are stored, and send MIDI until the buffer is empty. Using RTCC as the timer will allow me to re-check whatever midi input (buttons, ADCs, etc.) might have changed while sending bits, and re-load that into the buffer; care must me taken, however, that the data check doesn't take longer than the RTCC countup to 0x63 (w/the prescaling set by the !OPTION register... it's actually an eternity by SX time). This should make it easy to check inputs while sending data, thereby assuring no data is lost.
I've never actually needed to use the RTCC mid-bit check, as previous experiments with the forementioned code were satisfactory- no dropped data that I could detect.
If you use this in a project I'd like to hear about it! asmidius{at}gmail(dot)com
I thought you loved me... but you just wanted to see my bits... sniff... cry... wheeze... I feel so alone, and optoisolated
Source: http://asmidius.googlepages.com/midi...laxubicomsx-28


Rispondi Citando

Segnalibri