簡單說變數宣告auto_psv, 就是讓compiler把 const的變數都放在同一個 psv中(同一個32k), 所以auto_psv不能跟address同時使用
且宣告成autp_psv ,並不是不需要PSVPAG=__builtin_psvpage(xxx), 若const太多, 多到超過32k, 還是得在access前"手動"變更PSVPAG
小於32k時不需要,是因為都在同一個psv裡,(之前以為宣告成autp_psv, 就可以不需PSVPAG=__builtin_psvpage(xxx)...@@)
而在ISR宣告時
void __attribute__((interrupt, no_auto_psv)) _T1Interrupt(void) //不會備份PSVPAG, 所以響應快
void __attribute__((interrupt, auto_psv)) _T1Interrupt(void) //會備份PSVPAG, 但響應慢
=====================================================================================================
HW:Exp 16
SW:C30 3.23, IDE MPLAB 8.7
#include <p24fj128ga010.h> // Required for _CONFIG1 macro
#include <stdio.h> // Required for printf() function
#include "TLS2130.h" // Required for LCD routines
_CONFIG1(FWDTEN_OFF & JTAGEN_OFF)
//A..
//must set CORCONbits.PSV=1
const unsigned char __attribute__((space(psv),address(0x8000))) mystring1[]="abc";
const unsigned char __attribute__((space(psv),address(0x10000))) mystring2[]="edf";
//B..
//it doesn't need to set CORCONbits.PSV=1,but can't assigned address
//const unsigned char __attribute__((space(auto_psv))) mystring1[]="abc";
//const unsigned char __attribute__((space(auto_psv))) mystring2[]="edf";
//C..
//only use table read/write
//const unsigned char __attribute__((space(prog),address(0x8000))) mystring1[]="abc";
//const unsigned char __attribute__((space(prog),address(0x10000))) mystring2[]="edf";
int main(void)
{
/*---------------------------------------------------------------------------
Setup and write text to LCD to show program is working
---------------------------------------------------------------------------*/
lcdInit(); // Setup PMP and initialize LCD
//lcdPutStr("Hello, world!"); // Write text string to LCD
while(1){
PSVPAG=__builtin_psvpage(mystring1);
_PSV=1; //only need for A..
lcdPutStr(mystring1);
Nop();
PSVPAG=__builtin_psvpage(mystring2);
_PSV=1; //only need for A..
lcdPutStr(mystring2);
Nop();
}
}