Timer Interrupts - How to run code periodically?
Posted: Sun May 14, 2017 4:26 pm
Hello!
I am currently working on a library for an LCD. I am trying to make screen refreshes asynchronous. In order to do this, I would need to run the following code once every 500ns (125 cycles):
I'm thinking the best way to do this is with timer interrupts, but I've never worked with these before.
Any help or advice? Is there maybe a better method?
Thanks!
P.S. I may also want to tune the frequency manually...
I am currently working on a library for an LCD. I am trying to make screen refreshes asynchronous. In order to do this, I would need to run the following code once every 500ns (125 cycles):
Code: Select all
//screenDat is of type uint16_t[128*128]; Holds a copy of the screen's color data
//readLoc is of type byte*; Points to start of screenDat, reads it byte by byte (for speed)
//This function outputs screenDat one byte at a time via 8080 parallel
void LCD::tick(){//Updates the screen data. NO MORE OFTEN THAN ONCE EVERY 25 CYCLES(100 ns) - WILL BREAK EVERYTHING
GPIO.out&=(~0b111111111111); //Unset all 8080 pins, CMD mode
__asm__("nop\n\tnop"); //Delay a little. May be unnecissary
GPIO.out|= 0b011000000000|(*readLoc); //Enable write and chip, write data, DATA mode
readLoc++; //Increment address, not value!
if(readLoc==reinterpret_cast<byte*>(&screenDat+128*128*2))
readLoc=reinterpret_cast<byte*>(&screenDat); //Reset readLoc to beginning if it reaches the end
}
Any help or advice? Is there maybe a better method?
Thanks!
P.S. I may also want to tune the frequency manually...