memcpy_PF "“ possibly bugged function
The function does't work properly on at least XMEGA128A1 device. According to description the function should take a far pointer to FLASH location and copy len bytes into the SRAM location. The problem is as stated below:
memcpy_PF(&samplebuffer[0][0], srcaddr, BUFFER_SIZE): 00000112 MOVW R30,R20 Copy register pair 00000113 MOVW R26,R24 Copy register pair 00000114 RJMP PC+0x0003 Relative jump 00000115 LPM R0,Z+ Load program memory and postincrement 00000116 ST X+,R0 Store indirect and postincrement 00000117 SUBI R18,0x01 Subtract immediate 00000118 SBCI R19,0x00 Subtract immediate with carry 00000119 BRCC PC-0x04 Branch if carry cleared 0000011A RET Subroutine return
The memcpy_PF uses LPM instruction instead of ELPM and doesn't update RAMPZ register. So it effectively truncates source address to 16-bits and reads only first 64 kB of FLASH.
I didn't checked rest of *_PF functions but they should be revised too.