Pages: [1]   Go Down
Author Topic: Serial Communication with Timer0 Disabled?  (Read 424 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know quite a bit about programming but am new to hardware/electronics and finally stumbled into a problem I was unable to solve.

I made a synth, but the only way to get it to perform quickly enough is to do some timer magic:
Code:
// Apparently sets up Timer2?
  sbi (TCCR2B, CS20);    cbi (TCCR2B, CS21);    cbi (TCCR2B, CS22);
  cbi (TCCR2A, COM2A0);  sbi (TCCR2A, COM2A1);   
  sbi (TCCR2A, WGM20);    cbi (TCCR2A, WGM21);    cbi (TCCR2B, WGM22);

// Changes interrupts
  cbi (TIMSK0,TOIE0);              // disable Timer0 !!! delay() is now not available
  sbi (TIMSK2,TOIE2);              // enable Timer2 Interrupt

But when I do this I am unable to communicate with it over Serial in any sort of manner. I started messing around with software serials to see if that could solve the problem, but soon realized I don't know enough and had to find help.

The other half of this project is a little personal computer (Arduino Mega) that runs code off of the SD card, I want this Arduino Mega to be able to act as a sequencer: sending key presses and pitches to the synthesizer (Arduino Uno).

My current last resort is figuring out some complex mode of information transfer over several wires. This would require an additional arduino that only accepts commands from the Mega and converts them into a format for the synth, but this seems very wasteful.

Does anyone know how I can best accomplish this?
Logged

Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure the problem is specifically with the timer0 interrupt and not somewhere else? I'm thinking something that depends on timer0 that you got rid of by disabling the timer0 overflow interrupt.
I happen to have had some good optimization sessions recently, and I didn't find any noticable difference in speed by disabling the timer0 overflow interrupt.

You'd probably gain a lot more by compiling your sketch manually with different optimization params than what the IDE uses. The IDE uses -Os and you'd want -O2 or -O3 for something that really needs fast code more than small code.
Logged

Pages: [1]   Go Up
Jump to: