Hello. How much time does it take to read from ROM? I suppose it depends on how much it has to read? Suppose 3 arrays of 16 byte values. And also, how do i know how much memory i'm writing? I know that the data to be stored won't be dynamic, so it'll be always the same length. If i have an array of 16 values, byte variables, it'll take 16 bytes of ROM ? thanks
1 clock cycle per byte to read from Flash. See the clock cycles on Section 32 of the datasheet. When you Verify a sketch, the IDE returns "XXX oc 32xxx bytes". That's how many bytes are used. Unchanging arrays can be stored in PROGMEM & stored in flash. Arrays holding variables that are changed by the sketch (reading/storing from the serial port for example) are stored in SRAM, and there's a command you can put in your sketch that shows the amount of SRAM being used.
1 clock cycle per byte to read from Flash.
Try 3 clock cycles per byte. To read a byte from the Flash of an AVR requires the use of the “LPM” instruction which takes 3 clock cycles to read in a byte. It also takes time to set up the address pointer and to store the data you have read somewhere. Reading more than one consecutive byte at a time is more efficient as the LPM instruction can increment the address point for no extra time cost, so you only need to set up the address for the first.
1, 3 whatever it takes!
Thanks. I just wanted to see if i could switch between different presets in real time, it's a project for a live concert performer so...
Ok, so 48 clock cycles, 3uS? Pretty much instantaneous.