http://geekphysical.blogspot.com/
Our "advanced" offering is for the (nearly) elites in the field. You're good, very good in fact, but you could be better; there are methods and sneaky ways of tricking that clever little chip into listening to your every whim, and we're going to teach you them. Our first advanced workshop will focus on time-critical computing, making the most of every nano-second spent running your program. Time is wasted all the time waiting for the Arduino to complete its loops, to run through all its processes, but what if you could run processes in parallel?
The basic idea is to turn off all the background programs done by arduino and do all the program such as managing the interrupts by the avr-libc to call micro-controller's basic function. In this way, we can make sure our program will not be interrupted by some unknown signals. It is useful. When making some sounds, it will not delay. When receiving data, it will not lose data.
example code
#define SET(x,y) (x |=(1<
SIGNAL(SIG_OUTPUT_COMPARE1A)
{
OCR1A+=10000;
TOG(PORTB,5);
}
void setup()
{
}
void loop()
{
// Turn off all interrupts
TIMSK0=0;
TIMSK1=0;
TIMSK2=0;
EIMSK=0;
PCICR=0;
TCCR1A=0;
TCCR1B=0x03;
TCCR1C=0;
SET(TIMSK1,OCIE1A);
sei();
SET(DDRB,5);
while(1)
{
asm("nop");
}
}
No comments:
Post a Comment