That'll take awhile.... Paging the ROM tables 4 * 255 and there will be a significant frequency drop as the humble pic cannot do register to register addition...
I want to see how fast I can get it on an enhanced pic16...
That'll take awhile.... Paging the ROM tables 4 * 255 and there will be a significant frequency drop as the humble pic cannot do register to register addition...
I want to see how fast I can get it on an enhanced pic16...
The AVR version has a 32bit phase accumulator.
Maybe 24bit or even 16bit is enough for a simple DDS generator. That would be faster in a PIC.
In the other thread I posted a link, where PIC16F628 is running 32bit DDS code in a 100kHz interrupt loop.
As I first thought.... To use the tables you need a routine to access then... Or at least a mackro.... This will slow down the table access quite a bit... Without the large table code we are up to 16 cycles....
As I first thought.... To use the tables you need a routine to access then... Or at least a mackro.... This will slow down the table access quite a bit... Without the large table code we are up to 16 cycles....
Not sure I understand your question. The 18F (16-bit core) devices don't have "pages" as such. In 16F "enhanced mid-range" (14-bit core) devices you can indirectly access data or program memory anywhere in either address space without concern for "page" boundaries in program memory address space.
Not sure I understand your question. The 18F (16-bit core) devices don't have "pages" as such. In 16F "enhanced mid-range" (14-bit core) devices you can indirectly access data or program memory anywhere in either address space without concern for "page" boundaries when accessing program memory.
When I try to access the complete 255 values on a pic16f1826, the program goes nuts around item 0xFA... and reboots the micro.. That means it has crossed the page boundary... I must be using idea's from the midrange pics
Forgot to mention that for the DDS application the tables (sine, square, saw, triangle, etc.) should be org'd to 256 word boundaries to accomodate the phase accumulator math... Setup TBLPTRH (18F) or FSR1H (enhanced 16F) to point at the correct table before entering the DDS loop.
The compiler (XC8) or assembler (MPASM) will set FSRx bit 15 for you.
Code:
;
; setup FSR1 for 'sine' table (assembler knows 'sinetbl' label is
; in program memory and will will add 0x8000 to the address).
;
movlw low(sinetbl) ; sine table address lo
movwf FSR1L ;
movlw high(sinetbl) ; sine table address hi
movwf FSR1H ; FSR0 = &sinetbl
And here's an excerpt of code generated from an FSR0 = &sine statement in XC8 ( const char sine[] @ 0x0400 = {...} );
For this tiny project I preset the FSR1H to 0x81 ( the table starts at 0x100 )
Then all I need to do is set 1,2, 3 and 4 for each table..... At 16Mhz using a pic16f1826.. I have a 22.815 Khz sine....It will go faster but its starting to break up.... If a small filter is employed it would be quite smooth.
With your code its as fast as the AVR..... Just the serial interface to do now... Cheers Mike...
Are you sure? I thought AVR used one clock cycle per instruction cycle where PIC uses four clock cycles per instruction cycle. Isn't a 16-MHz AVR roughly equivalent to a 64-MHz PIC?