NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » MIDI over USART - Help
March 07, 2010 by jban4us |
Hi everyone! I'm working on a project that requires communicating with other devices over MIDI. I'm modifying a library found here that was written for ATmega8. Mostly I have it working, but working on receiving messages I've run into a problem. I've gotten receiving messages to work by polling, but I want it to work off of interrupts. The original library used an interrupt for receiving but I took it out and used polling to see if my midi circuit was correct. Here is the initialization code:
Main program file:
The problem is that when I turn it on, it says "Initializing" initializes the USART and then says "Initialized". But if I plug in the midi cable, it starts to flash "Initializing" over and over, and continues to do so even after removing the cable. It appears that something is happening to cause it to restart repeatedly. Any help would be appreciated, I've searched all over and it looks like I'm doing it right, but there is clearly a mistake somewhere! Thanks! |
---|---|
March 07, 2010 by jban4us |
Oops i forgot to mention that when i compile it gives a warning:
Looking at the data sheet this appears to be the right interrupt vector though, so I am not sure if this is the cause of the problem. |
March 07, 2010 by Rick_S |
I'll assume you are using an ATMega168 as supplied in the standard Nerdkit. If that is the case, your ISR is incorrect. Instead of
You should have
Now is you are using an ATmega16, ATmega32, ATmega323, or ATmega8 then it would be correct as you have it written. If you hadn't found it already, the complete list of innterupts available for any given micro is available at the avr-libc: Documentation Site. I'm not very proficient at C still so as to any other problems, I sorry if I can't be of much help. BTW, what are you trying to build?? Sounds interesting. It would be neat to turn my Kawai electronic piano into a player piano with songs of my choice... Good luck! Rick |
March 07, 2010 by jban4us |
Thanks! I am using the ATMega168. I changed the ISR to the correct one, and now it's receiving via interrupt. Thanks for the link too, it should be helpful in the future. Looking at the ATMega168 data sheet I found:
under the "Interrupt vectors in ATmega168" section, so I thought that's what it was. Perhaps avr-libc just uses USART_RX_vect instead for some reason? I'm building a control box for custom lighting effects for a DJ setup, to be controlled over MIDI via midi clock from Traktor and manually with an alesis micron. |
Please log in to post a reply.
Did you know that reading a double floating point variable with scanf requires "%lf" for "long float"? Learn more...
|