12.07.2015 Views

Section 4. Program Memory - Microchip Taiwan

Section 4. Program Memory - Microchip Taiwan

Section 4. Program Memory - Microchip Taiwan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

dsPIC33E/PIC24E Family Reference ManualExample 4-4 illustrates buffer placement and access in the user-managed PSV section. The psvspace is the user-managed PSV section.Example 4-4: User Managed PSV Access#include _FOSCSEL(FNOSC_FRC);_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_NONE);_FWDT(FWDTEN_OFF);const int m[5] = {1, 2, 3, 4, 5};const int m1[5] __attribute__ ((address(0x10000))) = {2, 4, 6, 8, 10};const int m2[5] __attribute__ ((address(0x20000))) = {3, 6, 9, 12, 15};int x[5] = {10, 20, 30, 40, 50};int sum, sum1, sum2;int vectordot (int *, int *);int main(void){int temp;// Save original PSV page valuetemp = DSRPAG;DSRPAG = __builtin_psvpage (m1);sum1 = vectordot ((int *) m1, x);DSRPAG = __builtin_psvpage (m2);sum2 = vectordot ((int *) m2, x);// Restore original PSV page valueDSRPAG = temp;sum = vectordot ((int *) m, x);}while(1);int vectordot (int *m, int *x){int i, sum = 0;}for (i = 0; i < 5; i ++)sum += (*m++) * (*x++);return (sum);DS70613B-page 4-18© 2010 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!