Your misunderstanding lies in the fact that "ADCClock" is not the "sampling rate", it is the internal clock with which the ADC module on the microcontroller works:
"Converting a single analog value to a 10-bit digital data requires sample and hold clock cycles as defined in the Sample and Hold Time field of the Mode Register (MR.SHTIM) and 10 ADC Clock cycles." (section 29.6.1, p. 792)
In other words, to get a single sample from your ADC requires actually quite a few (a minimum of 13 if my cursory read of the data sheet is correct) ADC clock cycles, and not just one. Your sampling rate is simply a function of how (often) you trigger a conversion (section 29.6.5). For this you would probably use one of the timer modules, which will most likely give you more flexibility in the actual intervals so you can achieve your 8kHz target rate.
Unless you tune your linker, the program will always start at address 0 and grow up. Additionally, if you have a bootloader, it will start at one of predefined addresses (either 0xF80, 0xF00, 0E00 or 0xC00, see table 26-7 in datasheet), and usually go to the top of the memory.
When people use flash memory for data, they usually put it as high as they can. So:
(1) Determine the memory top -- this depends on bootloader that you have. If you have Optiboot, it usually takes 512 or 256 words: https://code.google.com/p/optiboot/wiki/HowOptibootWorks , so we will assume it starts at 0xE00.
(2) Determine how much data you need. Lets say you need 256 (0x100) bytes. This means you will place your datablock at 0xE00 - 0x100 = 0xD00. You can pass values between 0xD00 and 0xDFE to boot_page_* functions.
(3) Write your program.
(4) Check how much space it occupies. It can take up to (0xD00 - 1) = 3328 bytes. When I compile from command-line, I use 'avr-size' for that:
$ avr-size -C --mcu=atmega328 firmware.elf
AVR Memory Usage
----------------
Device: atmega328
Program: 904 bytes (2.8% Full)
(.text + .data + .bootloader)
Data: 2 bytes (0.1% Full)
(.data + .bss + .noinit)
Look at 'program' section -- only 904 bytes are used, plenty of space left. If you see a number of 3328 or more there, make your program shorter. Otherwise, the program will compile and upload, but it will crash randomly.
Best Answer
I have little experience in Arduino but it looks like that line it's clearing the bits EXCLK and AS2.
From the context BV() should give you the bit weight.
AS2 is bit 5 (counting from the right starting from 0) on the register, then
_BV(AS2)
should return 32 (\$2^{5} = 64\$). By the same logic_BV(EXCLK)
should return 64 since EXCLK is bit 6.so in binary we have
_BV(AS2) = 00100000
and_BV(EXCLK) = 01000000
When we or these values we get 01100000
the
~
inverts the values so we get 10011111Then the
&=
keeps all the bits that are 1 on the previous result unchanged and sets the remaining bits (5 and 6) to 0.