??? 06/09/06 15:25 Read: times Msg Score: +1 +1 Informative |
#118103 - AT89S8252 Midi : Solved Problem |
problem was:
Establish a simple MIDI communication with 8051/52 derivative (my case at89s8252). Upon unsuccesfull receiving midi messages, thanks to pation people form this forum (AT89s8252 MIDI Baud Rate thread), numerous testing and code wtiring (soldering too) here is the results. First thing to interface Midi Out to uC is suitable optocoupler with sufficiently short transition time for supporting 31250 baud rate. I used PC817 causing me reception problems, looking like baud rate setup problem. 6N139 solved the problem, so here is two working example C codes for anybody interested in starting 8051/52 midi DIY project, and without much expirience. THIS CODE SENDS SIMPLE MIDI NOTE ON MESSAGE: #include <reg52.h> void Init (void) { // Uart Initialization 31250 baud, for 12 Mhz XTAL <pre> TMOD = 0x20; <pre> TL1 = 0xff; <pre> TH1 = 0xff; <pre> TCON = 0x50; <pre> SCON = 0x70; <pre> TR1 =1; } void wait ( unsigned integer i) { <pre> while(i--); } void main (void) { <pre> Init(); <pre> while(1) <pre> { <pre> SBUF=0x90; <pre> while(!TI); <pre> TI=0; <pre> SBUF=0x30; <pre> while(!TI); <pre> TI=0; <pre> SBUF=0x64; <pre> while(!TI); <pre> TI=0; <pre> wait(60000); <pre> } } THIS CODE IS SIMPLE MIDI THRU function: (usefull for looping back and testing communication) #include <reg52.h> unsigned char uart_data; void Init (void) { // Uart Initialization 31250 baud, for 12 Mhz XTAL <pre> TMOD = 0x20; <pre> TL1 = 0xff; <pre> TH1 = 0xff; <pre> TCON = 0x50; <pre> SCON = 0x70; <pre> TR1 =1; <pre> ES=1; <pre> EA=1; } void main (void) { <pre> Init(); <pre> while(1); } void serial_IT(void) interrupt 4 { <pre> if (RI == 1) // if reception occur <pre> { <pre> RI = 0;// clear reception flag for next reception <pre> uart_data = SBUF; // Read received data <pre> SBUF = uart_data; // Send back same data on uart <pre> } <pre> else TI = 0; // if emission occur // clear emission flag for nextemission } Anybody intrested in my future MIDI projects are invited to write me to dmitttri@hotmail.com for help, source codes etc... Thanks again to everyone who helped with this topic, without ironic flavour. Best, Dmitri |
Topic | Author | Date |
AT89S8252 Midi : Solved Problem | 01/01/70 00:00 | |
why the new thread???????? | 01/01/70 00:00 | |
At at least he posted his resolution![]() | 01/01/70 00:00 |